Skip to content
Path traversal Disclosed report Beginner

[hnzserver] Path Traversal allowing to read any files on the server

The hnzserver static file server did not sanitise path input, allowing an attacker to use dot-dot-slash sequences to read files outside the web root, including system files. This could expose sensitive data and potentially lead to further attacks such as remote code execution.

lightangel1412 Follow

Originally disclosed on HackerOne

High 7.5 View original
  • Triaged in 17 hours
  • Fixed in 15 months
  • Disclosed after 16 months

I would like to report path traversal vulnerability in module "hnzserver" It allows an attacker to read any files even system files via this path traversal vulnerability.

Module

module name: hnzserver version: 2.0.6 npm page: https://www.npmjs.com/package/hnzserver

Module Description

静态服务器 means "Static server"

Module Stats

[8] downloads in the last week [40] downloads in the last month [40] downloads in week 01-07 Apr

Vulnerability

##Vulnerability Description Path traversal attack (also known as directory traversal) aims to access files and directories that are stored outside the web root folder. By manipulating variables that reference files with “dot-dot-slash (../)” sequences and its variations or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system including application source code or configuration and critical system files.

##Steps To Reproduce:

  • Install the module
npm install -g hnzserver
  • Run 'hnzserver in "~/Desktop" directory :
root@kali:~/Desktop# hnzserver
server running is :http://localhost:8888
  • Use cURL to access etc/passwd file:
$ curl --path-as-is --url 'http://127.0.0.1:8888/../../../../etc/passwd'
hnzserver_-_PathTraversal.PNG
hnzserver_-_PathTraversal.PNG From the original on HackerOne

##Patch User input should be properly sanitized and filtered to remove dot-dot-slash (../)” sequences and its variations in path.

##Supporting Material/References:

  • Linux kali 4.15.0-kali2-amd64
  • node 10.15.3
  • npm 6.9
  • Firefox ESR 52.7.3 (64-bit)

##Wrap up

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

Impact

It could have enabled an attacker to view system files and leverage attacks like remote code execution and so on.

The original report as published on HackerOne, by lightangel1412. 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

Root cause

Likely the server did not sanitise or filter user-supplied paths to remove dot-dot-slash sequences before using them to read files.

Impact

An attacker could view system files and potentially leverage this to carry out attacks like remote code execution.

What the attacker needed

Hnzserver installed and running; network access to the server

How it was found

  1. Install the hnzserver module globally using npm.
  2. Run hnzserver from a directory such as the Desktop.
  3. Use cURL with the --path-as-is option to request a path containing dot-dot-slash sequences that reaches the system password file.

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 file server is meant to show only files inside a chosen folder. Here, by putting '../' in the web address, someone could make the server step up out of that folder and show any file on the computer, such as the system's password file. This is called path traversal.

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 lightangel1412

View all

5 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.