Skip to content

Commit 512ef0a

Browse files
committed
fix: Implement proper sandbox enforcement with corrected Landlock
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
1 parent 437268b commit 512ef0a

File tree

4 files changed

+1866
-34
lines changed

4 files changed

+1866
-34
lines changed

Cargo.toml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ base64 = "0.22"
108108
# HTTP date parsing (for Set-Cookie expires)
109109
httpdate = "1.0"
110110

111+
# Terminal styling
112+
colored = "3.1"
113+
indicatif = "0.18"
114+
unicode-width = "0.2"
115+
rpassword = "7"
116+
111117
# Matrix messenger support (optional)
112118
# Features: e2e-encryption (default), sqlite (persistence), rustls-tls (TLS)
113119
# rustls-tls is required when default-features = false
@@ -126,11 +132,9 @@ chromiumoxide = { version = "0.8", default-features = false, features = ["tokio-
126132
[target.'cfg(unix)'.dependencies]
127133
libc = "0.2"
128134

129-
# Terminal styling
130-
colored = "3.1"
131-
indicatif = "0.18"
132-
unicode-width = "0.2"
133-
rpassword = "7"
135+
# Landlock sandbox (Linux 5.13+ kernel)
136+
[target.'cfg(target_os = "linux")'.dependencies]
137+
landlock = "0.4"
134138

135139
# Patches for crypto compatibility
136140
[patch.crates-io]

0 commit comments

Comments
 (0)