-
Notifications
You must be signed in to change notification settings - Fork 207
fix(sandbox): allow exec in writable grant-dirs under command policies #1391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+197
−1
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caution
🔒 [HIGH · security] Granting subtree
AccessFs::Executeto writable directories (viaouter_exec_writable_dirs) inapply_outer_exec_gateintroduces a severe security bypass of thecommand_policiesexecution gate on Linux. A malicious sandboxed child can read any controlled binary (such asgitorkubectl), copy it into a writable directory (like the current working directory.or/tmp), and execute that copy directly. Because Landlock is strictly allow-list oriented and cannot express deny-within-allow, granting execution rights to the writable directory allows execution of any file inside it. This bypasses the shim and supervisor entirely, circumventing all argument filtering, policy rules, credential isolation, and auditing. To maintain the security boundary, this change must be reverted. Scripts should instead be executed by running their respective interpreters (e.g.,bash script.sh) directly, which does not require direct script execution privileges.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the accepted residual risk documented on #1390. A copied policed binary gains no elevation: credential promotion and proxy network bind to the verified supervisor handshake, not to whether a file is executable — so an unshimmed copy runs under the same fs/network limits as the agent, which can already write-and-run arbitrary code in a writable grant-dir when no
command_policiesexist. This bringscommand_policiesin line with that default. On Linux, Landlock is a strict allow-list with no deny-within-allow, and a copy has a fresh inode, so the exec gate cannot both permit new files in cwd to run and block a copied policed binary — the two are mutually exclusive. The original policed binary stays blocked from direct exec via the inode-identity gate.