Skip to content

permission: fix fs allowlist bypass on shared path prefixes#63813

Open
uwezkhan wants to merge 1 commit into
nodejs:mainfrom
uwezkhan:permission-prefix-end-node
Open

permission: fix fs allowlist bypass on shared path prefixes#63813
uwezkhan wants to merge 1 commit into
nodejs:mainfrom
uwezkhan:permission-prefix-end-node

Conversation

@uwezkhan

@uwezkhan uwezkhan commented Jun 9, 2026

Copy link
Copy Markdown

CreateChild in the fs permission radix tree marks a node as an end node whenever an inserted path runs through it, not only when a granted path ends there. Allowing three or more paths that share a common prefix is enough to trigger it: with --allow-fs-read set to /var/log/app1.log, /var/log/app2.log and /var/log/app3.log, the shared split node /var/log/app gets flagged as a leaf, and permission.has('fs.read', '/var/log/app') then returns true for a path that was never granted.

Before, the node was flagged the moment its prefix was fully matched, even when more of the inserted path remained to descend into. After, it is flagged only when the inserted path terminates exactly at that node. The tradeoff is nil for legitimate use: explicit grants, wildcard grants, and the end-node-with-children case from the comment above (/slow inserted after /slower and /slown) all keep working; the single behavioral change is that an unallowed common prefix is no longer treated as granted.

Inserting a path through an existing radix tree split node marked that
intermediate node as an end node, so a shared prefix of several granted
paths was treated as granted on its own. Mark a node as an end node only
when the inserted path terminates exactly at it.
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/security-wg

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants