(CVE-2023-32006) Permissions policies can impersonate other modules in using module.constructor.createRequire()
The experimental permissions policy mechanism in Node.js could be bypassed by using module.constructor.createRequire(), allowing a module to load other modules that the policy.json file did not permit. An attacker able to run code within a policy-restricted module could therefore reach modules outside its intended allowlist.
- Triaged in 44 hours
- Fixed in 30 days
- Paid in 30 days
- Disclosed after 60 days
Summary by the program
Permissions policies can impersonate other modules in using module.constructor.createRequire() (MEDIUM)(CVE-2023-32006) The use of module.constructor.createRequire() can bypass the policy mechanism and require modules outside of the policy.json definition for a given module.
Please note that at the time this CVE was issued, the policy mechanism is an experimental feature of Node.js.
Impacts:
This vulnerability affects all users using the experimental policy mechanism in all active release lines: 16.x, 18.x and, 20.x.
Thank you, to Axel Chong for reporting this vulnerability and thank you Rafael Gonzaga and Bradley Farias for fixing it.
The report
https://hackerone.com/reports/2043807
Patch was provided about maintainer opted for different approach.
Impact
see reports
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 policy check was applied to the normal require path but not to the alternative loader created through module.constructor.createRequire(), so that path skipped the allowlist check.
Impact
A module running under a permissions policy could load modules outside its policy.json definition, weakening the isolation the policy was meant to provide; the text notes the policy mechanism is experimental.
What the attacker needed
Experimental policy mechanism enabled
The fix
A patch was provided, but the maintainer opted for a different approach.
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 an administrator list which files a piece of code is allowed to load. This report says that list could be sidestepped by calling a built-in function in an unusual way, so code could load files it was not meant to.
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.