Repository navigation
permission: keep directories after radix tree split - #66852
Open
The-Peacemaker wants to merge 2 commits into
Open
The-Peacemaker wants to merge 2 commits into
The-Peacemaker wants to merge 2 commits into
Conversation
Granting two directories that share a prefix, such as /srv/app and /srv/appx, splits the radix tree node that holds the first directory's `/*` grant. The directory itself then stops being an end node, so fs.stat(), fs.readdir(), fs.access() and process.permission.has() deny access to an explicitly granted directory. Treat a node with an exact `/*` wildcard child as an end node, since granting `<dir>/*` also grants the directory itself. Fixes: nodejs#66812 Signed-off-by: Benedict Chacko <benedictcm1@gmail.com> Assisted-by: opencode
Nested grants (child first, then parent) split the radix tree inside the trailing `/*`, leaving the directory node with a trailing separator and a `*` child. Looking up the parent then failed because the wildcard was one level below the node and the node path had one extra character. Recognize both wildcard suffixes in IsEndNode() and accept a node whose path only appends the separator during lookup. Refs: nodejs#66812 Signed-off-by: Benedict Chacko <benedictcm1@gmail.com> Assisted-by: opencode
Collaborator
|
Review requested:
|
Contributor
|
Welcome to Node.js, and thank you for your first contribution! Before review, please take a moment to read:
Please make sure every commit is signed off. For a first pull request, GitHub Actions require collaborator approval and Jenkins CI must be started by a collaborator or triager, so an initial wait is normal. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #66812
Granting a directory inserts
<dir>/*into the permission radix tree. When a second grant splits that path, the directory node is no longer an end node, soprocess.permission.has(),fs.stat(),fs.readdir(), andfs.access()returnERR_ACCESS_DENIEDfor the directory the user explicitly granted.Two split shapes are fixed:
/srv/app,/srv/appx) leave<dir>with separate/*andx/*wildcard children./srv/app/nested, then/srv/app) leaves<dir>/with a*child.IsEndNode()now recognizes a direct*or/*wildcard child, andLookup()accepts a node whose path only appends the path separator. Granting<dir>/*already grants<dir>when the tree is not split, so this restores the existing behavior rather than adding a new grant.test/parallel/test-permission-fs-prefix-split.jscovers sibling grants in both orders, nested grants in both orders, read/write scopes, and a denied prefix sibling. The test reproduces the bug on v22.17.1.