[serve-here] Static Web Server Directory Traversal via Crafted GET Request
The serve-here static web server did not properly sanitise URL-encoded path traversal sequences in GET requests, allowing an attacker to read files outside the web root. An attacker could request arbitrary files such as /etc/passwd from the host.
- Triaged in 29 hours
- Fixed in 32 days
- Disclosed after 33 days
Summary by the researcher
A crafted request can be used to traverse the directory structure of a host using the serve-here package, and request arbitrary files outside of the specified web root. Thanks again to @vdeturckheim for handling this report, and to @vivaxy for the fix.
The report
Hi,
A crafted GET request can be leveraged to traverse the directory structure of a host using the serve-here web server package, and request arbitrary files outside of the specified web root.
Module specification
- Name: serve-here
- Version: 3.2.0 (latest release build)
Verified conditions
- Test server: Ubuntu 16.04 LTS
- cURL package:
curl 7.55.1 (2017-08-14)
Proof of concept
Please install the serve-here package and cd to a chosen directory (in this case, /root) on your test server. Next, run here -p 8081 to start serving from this location.
Substituting the <server-IP> value as appropriate, the following cURL request can be used to demonstrate this vulnerability by requesting the target /etc/passwd file:
curl "http://<server-IP>:8081/..%2f..%2fetc/passwd"
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
[...]
Thanks,
Yasin
Impact
An adversary can leverage this vulnerability to request arbitrary files from the target host, which may include application source code or system files.
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 adversary can leverage this vulnerability to request arbitrary files from the target host, which may include application source code or system files.
What the attacker needed
Serve-here package running; network access to the server
How it was found
- Install the serve-here package and change to a chosen directory on the test server.
- Start the server with the command 'here -p 8081' to serve from that location.
- Send a crafted GET request containing URL-encoded traversal sequences to request a file outside the web root, such as /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 web server normally only lets you see files inside the folder it is told to share. Here, by putting special characters in the web address, someone could make the server show files from other folders on the computer, like system password files. This is called directory traversal.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.