Skip to content
Path traversal Disclosed report Intermediate CVE-2023-30584

Filesystem experimental permissions policy does not handle path traversal cases.

The experimental Node.js filesystem permission policy checked the requested path as a string against the allowed directory, so a path containing a parent-directory segment matched the check but resolved to a file outside the restricted folder. An attacker able to run code under this policy could therefore write to files the policy was meant to protect.

haxatron1 Follow

Originally disclosed on HackerOne

High 7.7 View original
  • Triaged in under an hour
  • Fixed in 2 months
  • Disclosed after 3 months

Consider the following command on Node v20.0.0:

node --experimental-permission --allow-fs-read=* --allow-fs-write=/home/kali/restricted/ poc.js

This command is intended to restrict write access to only files present in the directory /home/kali/restricted

However if we have the following poc.js:

const fs = module.require('fs')
fs.writeFileSync("/home/kali/restricted/../secret.txt", "Target Overwritten!")

This apparently matches the directory /home/kali/restricted/ directory check and then writes to /home/kali/secret.txt (by using ../), which is not intended, bypassing the experimental permission policy for files.

Impact

Path traversal when checking experimental file permission policy

The original report as published on HackerOne, by haxatron1. 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 permission check compared the unresolved path string against the allowed directory instead of resolving it to a canonical path before deciding.

Impact

A program running under the experimental permission policy could write to files outside the allowed directory, defeating the restriction.

What the attacker needed

Ability to run Node with the permission flag; control over the path passed to fs

How it was found

  1. Start Node with the experimental permission flag, allowing all reads and writes only to the restricted directory.
  2. Run a script that writes to a path inside the restricted directory followed by a parent-directory segment and a filename outside it.
  3. Observe that the write succeeds outside the restricted directory.

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.

Node.js has an experimental mode that is supposed to limit which files a program may read or write. The check compared the path text against the allowed folder, but a path can look like it is inside that folder while actually pointing somewhere else once the operating system resolves the '..' part, which means 'go up one folder'. So the program could still write outside the intended folder.

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 haxatron1

View all

30 more disclosed reports, best first.

More from Node.js

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.