Permission model improperly processes UNC paths
The Node.js Permission Model's path-checking function wrongly assumes every path beginning with two backslashes has a four-character prefix that can be skipped. An attacker could therefore reach a UNC network path that was never granted, even when only local drive access was allowed.
- Triaged in 8 days
- Fixed in 12 months
- Disclosed after 12 months
Summary by the program
The Permission Model assumes that any path starting with two backslashes \ has a four-character prefix that can be ignored, which is not always true. This subtle bug leads to vulnerable edge cases.
This vulnerability affects Windows users of the Node.js Permission Model in version v20.x and v22.x
The report
The is_tree_granted function in fs_permission.cc assumes that any path starting with two backslashes \\ has a four-character prefix that can be ignored, which is not always true. This subtle bug leads to vulnerable edge cases.
Steps To Reproduce:
With a recent version of Node.js 20, run a command such as:
node --experimental-permission --allow-fs-read=C:\* -p "fs.readdirSync(Buffer.from('\\\\A\\C:\\Users'))"
The expected behavior is an ERR_ACCESS_DENIED error, but it does not occur. Instead, Node.js calls scandir on \\A\C:\Users.
Supporting Material/References:
Impact
An attacker can potentially gain unintended access to UNC resources. In the above example, an attacker gains file system access to the UNC path \\A\C:\, even though no access beyond the local C:\ drive has been granted.
It is difficult to fully and accurately comprehend the impact. The bug is subtle, and Windows uses notoriously complex file path formats. Overall, I consider the severity of the issue to be low.
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 is_tree_granted function assumes any path starting with two backslashes has a four-character prefix that can be ignored, which is not always true for Windows UNC paths.
Impact
An attacker could potentially gain file system access to a UNC path such as a remote share even though only the local drive was granted; the reporter rates the severity as low.
What the attacker needed
Windows host; Node.js 20.x or 22.x; Permission Model enabled; Attacker can run a script under it
How it was found
- Run Node.js 20 with the experimental permission flag and read access limited to the local C drive.
- Call a filesystem function with a path built from a buffer that begins with two backslashes followed by a UNC-style path.
- Observe that no access-denied error is raised and the directory is listed instead.
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 may read. On Windows, paths can start with two backslashes to mean a shared folder on another machine, and the check for allowed paths got this format wrong. So a script could read a network share even though only a local drive was permitted.
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.