Skip to content
Access control Disclosed report Intermediate CVE-2023-32005

fs.statfs bypasses Permission Model

The experimental permission model in Node.js 20 failed to restrict the fs.statfs API, so a script running with limited file-read permissions could still retrieve filesystem statistics for paths it was not allowed to read. This let an attacker check whether a file exists and gather metadata about it, though not read its contents.

rafaelgss Follow

Originally disclosed on HackerOne

  • Triaged in under an hour
  • Fixed in 35 days
  • Disclosed after 2 months

Summary by the program

A vulnerability has been identified in Node.js version 20, affecting users of the experimental permission model when the --allow-fs-read flag is used with a non-* argument.

This flaw arises from an inadequate permission model that fails to restrict file stats through the fs.statfs API. As a result, malicious actors can retrieve stats from files that they do not have explicit read access to.

This vulnerability affects all users using the experimental permission model in Node.js 20.

Please note that at the time this CVE was issued, the permission model is an experimental feature of Node.js.

The report

Summary:

fs.statfs is not limited by the permission model check

Description:

fs.statfs doesn't throw ERR_ACCESS_DENIED when accessing an restricted path, being able to get stat information of the file

Steps To Reproduce:

CONSOLE
touch ./test.js
JavaScript
// index.js
const fs = require('fs')

fs.statfs('./test.js', (err, stats) => {
  console.log('stats', stats)
})
$ node --experimental-permission --allow-fs-read=/path/to/index.js
(node:756097) ExperimentalWarning: Permission is an experimental feature
(Use `node --trace-warnings ...` to show where the warning was created)
stats StatFs {
  type: 61267,
  bsize: 4096,
  blocks: 56377128,
  bfree: 27380986,
  bavail: 24498982,
  files: 14393344,
  ffree: 12478020
}

Impact

Even though it can't read the file contents, it's still can perform I/O against that file to retrieve file stats and to check if a file exists.

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

The permission model's read-access check was not applied to the fs.statfs API, so it bypassed the restriction.

Impact

An attacker could perform I/O against a restricted file to retrieve its stats and check whether it exists, but could not read its contents.

What the attacker needed

Node.js 20 with experimental permission model; --allow-fs-read set to a non-* path

How it was found

  1. Create a test file.
  2. Write a script that calls fs.statfs on that file.
  3. Run Node.js with the experimental permission flag and a read allow-list that does not include the test file.
  4. Observe that fs.statfs returns statistics instead of an access-denied error.

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 feature that lets you limit which files a script can read. The check for that limit was missing on one function that returns information about a file, such as its size and whether it exists. So a script could still learn things about files it was not supposed to touch, even though it could not open and read them.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by rafaelgss

View all

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

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.