Skip to content
Path traversal Disclosed report Beginner

[public] Path traversal using symlink

The public static file server follows symbolic links placed inside the served directory, allowing an attacker to read arbitrary files on the server. By creating a symlink to a sensitive file and requesting it, the file's contents are disclosed.

henrychen Follow

Originally disclosed on HackerOne

Medium 4.2 View original
  • Triaged in 32 hours
  • Fixed in 57 days
  • Disclosed after 3 months

I would like to report Path traversal vulnerability in public module

Module

module name: public version: 0.1.4 npm page: https://www.npmjs.com/package/public

Module Description

Run static file hosting server with specified public dir & port. Support a "direcotry index" like Apache httpd.

Module Stats

105 downloads in the last week

Vulnerability

Vulnerability Description

Path traversal using symlink.

Steps To Reproduce:

  • Install public
npm install public -g
  • Run public server
➜  public ./bin/public                 
Public.js server running with "/home/xxx/h1/node_modules/public" on port 3000
  • Create a symlink inside your project directory.
$ ln -s /etc/passwd test_passwd
  • Request the file with curl
$ curl http://127.0.0.1:3000/test_passwd
root:x:0:0:root:/root:/bin/bash
1.png
1.png From the original on HackerOne

Patch

providing a flag to disable/enable following symlinks.

Supporting Material/References:

  • Ubuntu 16.04
  • node v11.8.0
  • npm 6.5.0

Wrap up

  • I contacted the maintainer to let them know: [N]
  • I opened an issue in the related repository: [N]

Impact

It allows attacker to read content of arbitary file on remote server.

The original report as published on HackerOne, by henrychen. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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 arbitrary files on the remote server, potentially exposing sensitive information.

What the attacker needed

Ability to create a symlink in the served directory; network access to the server

The fix

The reporter suggests providing a flag to disable or enable following symlinks.

How it was found

  1. Install the public module globally.
  2. Run the public server.
  3. Create a symbolic link inside the served directory pointing to a sensitive file.
  4. Request the symlink via HTTP to retrieve the 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 symbolic link (symlink) is like a shortcut that points to another file. The public server was supposed to only serve files inside its public folder, but it also followed these shortcuts, so someone could create a shortcut to a private file like /etc/passwd and then download it through the web server.

What is Path traversal?

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.

More from Node.js third-party modules

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.