Skip to content
Path traversal Disclosed report Intermediate

[node-downloader-helper] Path traversal via Content-Disposition header

The node-downloader-helper library did not sanitise the filename taken from a server's Content-Disposition header, so a malicious server could use ../ sequences to write the downloaded file outside the intended directory. The reporter claims this could lead to remote code execution by placing an executable in a Windows startup folder or an authorised_keys file on Linux.

ryotak Follow

Originally disclosed on HackerOne

Medium 4.6 View original
  • Triaged in 10 hours
  • Fixed in 9 months
  • Disclosed after 10 months

Summary

I would like to report path traversal in node-downloader-helper. It allows malicious server to choose download location via ../. It may leads remote code execution.

Module

module name: node-downloader-helper version: 1.0.11 npm page: https://www.npmjs.com/package/node-downloader-helper

Module Description

A simple http file downloader for node.js

Features:

  • No thirdparty dependecies
  • Pause/Resume
  • Retry on fail
  • Supports http/https
  • Supports http redirects
  • Supports pipes
  • Custom native http request options
  • Usable on vanilla nodejs, electron, nwjs
  • Progress stats

Module Stats

13,911 weekly downloads

Vulnerability

Vulnerability Description

Since there is no sanitization of file path, malicious server is able to traversal path of victim machine. It leads remote code execution by putting malicious executable to startup folder in Windows. (In Linux, it's possible to create authorized_key.).

Steps To Reproduce:

  1. Put poc.php to the server. (or you can use my server's PoC: https://exec.ga/download-test.php )
  2. Modify poc.js to set URL of the poc.php
  3. Execute node poc.js
  4. evil.txt will be saved to parent directory of the directory which contains poc.js

Supporting Material/References:

  • Windows 10
  • v12.13.1
  • 6.12.1

Wrap up

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

Impact

Attacker is able to put malicious contents anywhere of victim's machine.

The original report as published on HackerOne, by ryotak. 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 controlling the download server could write malicious content anywhere the victim's user account can write, which may lead to remote code execution.

What the attacker needed

Victim downloads from an attacker-controlled server; user account can write to target folder

How it was found

  1. Host a file on a server that returns a crafted Content-Disposition filename.
  2. Point the downloader script at that server's URL.
  3. Run the script with node.
  4. Observe that the downloaded file is written to the parent directory instead of the expected folder.

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.

When you download a file, the server can suggest a name for it. This library trusted that suggested name completely, so a name containing '../' could make the file land in a folder above the one you expected. A malicious server could therefore drop a file almost anywhere the user can write, which is dangerous if that location is one the system runs automatically.

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 ryotak

View all

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