Path traversal by monkey-patching Buffer internals
The Node.js permission model resolves user-supplied paths with path.resolve() and then converts them to a Buffer using Buffer.from(). An attacker who can monkey-patch Buffer.prototype.utf8Write can alter the resolved path, enabling path traversal.
- Triaged in 10 hours
- Fixed in 4 months
- Disclosed after 4 months
Summary by the program
The permission model protects itself against path traversal attacks by calling path.resolve() on any paths given by the user. If the path is to be treated as a Buffer, the implementation uses Buffer.from() to obtain a Buffer from the result of path.resolve(). By monkey-patching Buffer internals, namely, Buffer.prototype.utf8Write, the application can modify the result of path.resolve(), which leads to a path traversal vulnerability.
This vulnerability affects all users using the experimental permission model in Node.js 20 and Node.js 21.
Please note that at the time this CVE was issued, the permission model is an experimental feature of Node.js.
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 model relies on Buffer.from() to convert the resolved path, and Buffer.from() can be influenced by a monkey-patched Buffer.prototype.utf8Write, so the path used later differs from the one that was checked.
Impact
An attacker could cause path traversal, but only when the experimental permission model is enabled.
What the attacker needed
Experimental permission model enabled; ability to monkey-patch Buffer internals
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 permission model that is supposed to stop code from accessing files outside allowed folders. It checks paths by turning them into a standard form and then into a Buffer (a way to hold raw bytes). If an attacker can replace a built-in Buffer function, they can change the path after the check, so the program ends up using a different path that escapes 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.