[harp] Path traversal using symlink
The harp development web server follows symbolic links placed inside the served project directory, so a link pointing outside the web root is served as a normal file. An attacker who can get such a link into the project could read files outside the intended directory, such as the system password file.
- Triaged in 13 hours
- Fixed in 3 days
- Disclosed after 3 days
In reference to #453820
Module
module name: harp
version: 0.29.0
npm page: https://www.npmjs.com/package/harp
Module Description
zero-configuration web server with built in pre-processing
Module Stats
2,679 downloads in the last week
Vulnerability
Path traversal using symlink.
Vulnerability Description
Similar to #403703. It can be used to list any file in another folder of web root.
Steps To Reproduce
- Install harpjs
yarn global add harp
- Run harp server
harp server
- Create a symlink inside your project directory.
$ ln -s ../../../../../etc/passwd sympasswd
- Request the file with curl
$ curl --path-as-is 0.0.0.0:9000/sympasswd
root:x:0:0:root:/root:/bin/bash
...
Patch
Educating users about this behaviour in the docs and probably providing a flag to disable/enable following symlinks.
Supporting Material/References:
- Ubuntu 16.04
- node v11.3.0
- npm 6.4.1
Wrap up
- I contacted the maintainer to let them know: Y
- I opened an issue in the related repository: Y
Impact
You can access files outside project directory through server via symlink.
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 resolves and serves symbolic links without checking that the real target stays inside the web root.
Impact
Files outside the project directory can be read through the server via a symlink, though this requires the ability to place a link in the served directory.
What the attacker needed
Ability to create a symlink in the project; harp server running locally
The fix
The maintainer proposed documenting the behaviour and probably adding a flag to enable or disable following symlinks; the text does not say it was fixed.
How it was found
- Install the harp package globally.
- Start the harp server.
- Create a symbolic link inside the project directory that points to a file outside it.
- Request the link's name from the server and receive the outside file's contents.
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 hands out files from the folder it was told to serve. A symbolic link is a shortcut file that points at another file elsewhere on the disk. Here the server followed such shortcuts without checking where they lead, so a shortcut placed in the project folder let the server hand out a file from outside that folder.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.