fs.openAsBlob() bypasses permission system
Node's experimental permission system did not restrict the fs.openAsBlob() function, so a script running with --experimental-permission could still read a file it had not been granted access to. An attacker able to run code in such a process could read files outside the intended permission boundary.
- Triaged in under an hour
- Fixed in 52 days
- Disclosed after 3 months
Summary: [add summary of the vulnerability]
fs.openAsBlob() does not appear to be limited by the permission system.
Description: [add more details about this vulnerability]
Starting Node with --experimental-permission does not appear to restrict fs.openAsBlob().
Steps To Reproduce:
Run the following code with --experimental-permission and do not grant is read access to file.txt:
'use strict';
const fs = require('node:fs');
async function main() {
const blob = await fs.openAsBlob(__dirname + '/file.txt');
console.log(await blob.text());
}
main();
Impact: [add why this issue matters]
The permission system is bypassed when it should not be.
Supporting Material/References:
None
Impact
An attacker can read files they should not be able to.
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 some file-reading APIs but not to the newer fs.openAsBlob() function, leaving a gap in enforcement.
Impact
The permission system is bypassed, so an attacker could read files they should not be able to.
What the attacker needed
Ability to run code in a Node process; process started with --experimental-permission
How it was found
- Start Node with the experimental permission flag and do not grant read access to the target file.
- Call fs.openAsBlob() on that file from a script.
- Read the returned blob's text and observe the file contents despite the missing 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 mode that lets you say which files a program is allowed to read. The idea is that even if someone slips bad code into the program, it cannot open files you did not allow. Here, one particular way of opening a file was simply not checked by that mode, so the restriction could be sidestepped.
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.