[http_server] Path Traversal allowing to read any files on the server
The http_server npm module fails to sanitise file paths, allowing an attacker to use dot-dot-slash sequences to read files outside the web root, including system files. This could lead to viewing sensitive files and potentially further attacks such as remote code execution.
Originally disclosed on HackerOne
- Triaged in 17 hours
- Fixed in 15 months
- Disclosed after 16 months
I would like to report path traversal vulnerability in module "http_server" It allows an attacker to read any files even system files via this path traversal vulnerability.
Module
module name: http_server version: 1.0.12 npm page: https://www.npmjs.com/package/http_server
Module Description
一个静态服务器 means "a static server"
Module Stats
[14] downloads in the last week [116] downloads in the last month
Vulnerability
##Vulnerability Description Path traversal attack (also known as directory traversal) aims to access files and directories that are stored outside the web root folder. By manipulating variables that reference files with “dot-dot-slash (../)” sequences and its variations or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system including application source code or configuration and critical system files.
##Steps To Reproduce:
- Install the module
npm install -g http_server
- Run 'http_server in "~/Desktop" directory :
root@kali:~/Desktop# http_server
server running is :http://localhost:8888

- Use cURL to access etc/passwd file:
$ curl --path-as-is --url 'http://localhost:8888/../../../../../etc/passwd'

##Patch User input should be properly sanitized and filtered to remove dot-dot-slash (../)” sequences and its variations in path.
##Supporting Material/References:
- Linux kali 4.15.0-kali2-amd64
- node 10.15.3
- npm 6.9
- Firefox ESR 52.7.3 (64-bit)
##Wrap up
- I contacted the maintainer to let them know: N
- I opened an issue in the related repository: N
Impact
It could have enabled an attacker to view system files and leverage attacks like remote code execution and so on.
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
Root cause
Likely the server did not sanitise or normalise user-supplied file paths, allowing directory traversal sequences to escape the web root.
Impact
It could have enabled an attacker to view system files and leverage attacks like remote code execution and so on.
What the attacker needed
Http_server module installed and running; network access to the server
How it was found
- Install the http_server module globally using npm.
- Run the http_server command in a directory such as the Desktop.
- Use cURL with the --path-as-is option to request a path containing dot-dot-slash sequences that points to a system file like /etc/passwd.
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 static server is a program that serves files from a folder over the web. This server did not check that requested file paths stayed inside that folder, so someone could ask for files elsewhere on the computer, like system password files, by using '../' to climb out of the folder.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.