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

fs module's file watching is not restricted by --allow-fs-read

The Node.js permission system's read restriction did not cover file watching, so a script without read access could still monitor a file. An attacker could therefore learn when a file they should not be able to read was modified.

cjihrig Follow

Originally disclosed on HackerOne

Medium 4.4 View original
  • Triaged in 18 hours
  • Fixed in 52 days
  • Disclosed after 3 months

Summary: [add summary of the vulnerability] The --allow-fs-read flag of the permission system does not prevent file watching.

Description: [add more details about this vulnerability] Attackers can watch files that they don't have read access to.

Steps To Reproduce:

Run the following code with --experimental-permission and do not grant read access to file.txt. Modify file.txt in another process. Information is leaked to the attacker about a file they should not have access to.

JavaScript
'use strict';
const fs = require('node:fs');

async function main() {
	fs.watchFile(__dirname + '/file.txt', () => {
		console.log('able to watch a file without any permissions');
	});
}

main();

Impact: [add why this issue matters]

The permission system is bypassed. Attackers can receive events related to files they do not have access to.

Supporting Material/References:

None

Impact

The permission system is bypassed.

The original report as published on HackerOne, by cjihrig. 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 was applied to file read operations but not to the file watching API, leaving that path unchecked.

Impact

The permission system could be bypassed, letting an attacker receive events about files they do not have access to.

What the attacker needed

Experimental permission system enabled; attacker can run a script under it

How it was found

  1. Run a script with the experimental permission flag and no read access to the target file.
  2. Have the script watch that file for changes.
  3. Modify the file from another process.
  4. Observe that the watching script receives change events despite lacking read permission.

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 optional permission system that lets you say which files a script may read. This report shows that one file-related feature, watching a file for changes, was not covered by that restriction. So a script could still be told when a file changed even though it was not allowed to read the file.

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 cjihrig

View all

1 more disclosed report, 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.