fix: Implement proper sandbox enforcement with corrected Landlock#57
Merged
fix: Implement proper sandbox enforcement with corrected Landlock#57
Conversation
9221f2b to
e004800
Compare
Based on security findings from @aecs4u (PR #21), with critical Landlock fix. ## Security Issues Fixed 1. **PathValidation was no-op** — now properly validates against deny lists 2. **Background commands bypassed sandbox** — now wrapped before spawning 3. **Landlock semantics were inverted** — CRITICAL: original code would ALLOW credentials instead of denying them ## Landlock Fix (the critical change) The original implementation misunderstood Landlock's security model. Landlock is ALLOWLIST-based: you specify what IS allowed, everything else is denied. The fix: - Allow system paths: /usr, /lib, /bin, /etc, /proc, /sys, /dev (read) - Allow temp paths: /tmp, /var/tmp (read+write) - Allow workspace (full access) - Credentials denied BY OMISSION (not in allowlist = denied) ## Changes (cherry-picked from PR #21, sandbox commits only) - src/sandbox.rs: Complete sandbox implementation with corrected Landlock - docs/SANDBOX.md: Comprehensive documentation - tests/sandbox_enforcement.rs: Integration tests ## Attribution Security finding and initial implementation by @aecs4u. Landlock semantics fix reviewed against Landlock API docs. Closes #22 Supersedes #21
e004800 to
512ef0a
Compare
7 tasks
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
Implements proper sandbox enforcement based on security findings from @aecs4u (PR #21), with a critical fix to the Landlock implementation.
Security Issues Fixed
The Landlock Bug (Critical)
The original PR #21 implementation misunderstood Landlock's security model:
Landlock is ALLOWLIST-based: you specify what IS allowed, and the kernel denies everything else. The original code would have ALLOWED access to credentials instead of denying them!
The Fix
Changes
src/sandbox.rs: Complete sandbox implementation with corrected Landlockdocs/SANDBOX.md: Comprehensive documentation (927 lines)tests/sandbox_enforcement.rs: Integration testsSandbox Modes Supported
Attribution
References