fix: enforce POSIX ancestor dir permission checks on path ops#405
Draft
toddr-bot wants to merge 1 commit into
Draft
fix: enforce POSIX ancestor dir permission checks on path ops#405toddr-bot wants to merge 1 commit into
toddr-bot wants to merge 1 commit into
Conversation
…perations
POSIX requires execute (search) permission on every ancestor directory
when resolving a path. Previously, only _check_parent_perms() verified
the immediate parent, allowing operations like unlink('/a/b/c/file')
to succeed even when the mock user lacked execute on '/a' or '/a/b'.
Introduces _check_path_perms($path) which walks all ancestor directories
from root to parent, checking execute permission on each mocked dir.
Wired into: stat, lstat, open, sysopen, opendir, unlink, readlink,
symlink, link, mkdir, rmdir, rename, chmod, chown, utime, truncate.
Filehandle-based stat and truncate bypass the check (handle already open).
Root traversal follows existing _check_perms() logic (needs >= 1 x bit).
Closes cpan-authors#390.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
What
Adds
_check_path_perms($path)— POSIX path traversal enforcement that checks execute (search) permission on all ancestor directories, not just the immediate parent.Why
Issue #390:
_check_parent_permsonly verified the immediate parent directory. Operations likeunlink('/a/b/c/file')succeeded even when the mock user lacked execute on/aor/a/b. Real POSIX systems require execute on every directory component during path resolution.This also supersedes PR #372 which only wired the check into stat/lstat.
How
_check_path_perms($path)walks from root (/) through each ancestor directory, checking execute permission on each mocked dir via existing_check_perms(). Non-mocked ancestors are skipped (assumed accessible).Testing
t/ancestor_perms.twith 19 subtests covering all wired operations:Closes #390
Supersedes #372
🤖 Generated with Claude Code
Quality Report
Changes: 2 files changed, 426 insertions(+)
Code scan: clean
Tests: failed (4 Failed, 95 test)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline