Reject world-writable components in exec-suid script paths - #18
Merged
Conversation
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.
Summary
/tmp./tests/tmp.Rationale
Root ownership alone is insufficient when a path component is writable by other users.
For example, when
fs.protected_hardlinks=0, an unprivileged user may be able to create a hardlink in/tmpto a root-owned setuid script and give it an option-like name such as-c<payload>.If the privileged script uses an interpreter header such as:
and the hardlink is invoked using that relative spelling,
exec-suidappends the path verbatim to the interpreter arguments:Python can interpret this as its
-coption and execute the filename payload with the privileges selected from the setuid script.The hardlink still refers to a root-owned inode, so ownership validation does not reject it. The sticky bit on
/tmprestricts removing or renaming entries owned by other users, but it does not prevent users from creating new entries.Rejecting every other-writable path component prevents setuid scripts from being reached through these attacker-controlled locations. It also avoids depending on the current hardlink-protection sysctl, which cannot account for links created while protection was disabled.
The same rule applies to the target script itself: a root-owned but world-writable privileged script should not be trusted.
This intentionally means that setuid scripts beneath
/tmpor another world-writable directory are no longer accepted, even when the directory has the sticky bit.Validation
git diff --checkpasses.