fix: enforce POSIX sticky bit on unlink/rmdir/rename#369
Draft
toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
Draft
fix: enforce POSIX sticky bit on unlink/rmdir/rename#369toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
Conversation
POSIX requires that when a directory has the sticky bit set (mode 01000, e.g. /tmp with mode 1777), only the file owner, directory owner, or root can delete or rename entries. Without this check, any user with write permission on the directory could remove other users' files. Adds S_ISVTX constant, _check_sticky_bit() helper, and enforcement in __unlink, __rmdir, and __rename (both source and destination dirs). 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
Enforce sticky bit (S_ISVTX / 01000) restrictions on
unlink(),rmdir(), andrename()whenset_user()is active.Why
POSIX requires that directories with the sticky bit (e.g.,
/tmpmode 1777) restrict deletion/renaming to the file owner, directory owner, or root. Without this check, any user with write permission on a sticky directory can remove other users' files — breaking the security model thatset_user()is designed to test.How
S_ISVTXconstant (01000) alongside existingS_IF*constants_check_sticky_bit($parent_path, $file_path)helper: checks if parent dir has sticky bit, and if so, verifies the mock user is the file owner, dir owner, or root__unlink,__rmdir, and__rename(both source and destination parent dirs for rename)Testing
t/sticky_bit.tcovering:fh-ref-leak.tfailure)🤖 Generated with Claude Code
Quality Report
Changes: 2 files changed, 235 insertions(+)
Code scan: clean
Tests: failed (4 Failed, 95 test)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline