fix(kvb-org-organize): no hook runs a binary planted on the inherited PATH
Hooks run outside the sandbox but inherit a PATH whose directories sandboxed agents of the same uid can write (a virtualenv's bin activated first by the shell profile), so a file planted there under the name of docker, git or notify-send ran unsandboxed. hookpath.py keeps only the PATH directories that, with every parent, belong to another uid and that neither group nor others can write, as real paths; inside the sandbox's user namespace root shows as the overflow uid and still counts as sealed. watch.py, radio.py and council.py set that PATH before they start anything, and the cleanup child runs with -I. Both reminder hooks pin PATH=/usr/bin:/bin, and the install registers them with /usr/bin/bash and moves older bare bash and python3 entries to the absolute paths. 🎯 Fix: 90 % 💥 Break: 4 % 💸 Cost: 100 % ⏱️ Time: 100 % 🛡️ Security: 100 % 💰 Value: ? 🏆 Score: 86 🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 % Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
94542e7b92
commit
454670a77e
13 files changed
+193
-5
No files matched your search
@@ -416,6 +416,24 @@ class TestRadio(unittest.TestCase):
|
||||
self.assertEqual(self._tool("s2"), ["MAYDAY One: fire"])
|
||||
self.assertEqual(os.listdir(victims), [])
|
||||
|
||||
def test_the_operator_notice_runs_no_binary_planted_on_the_path(self):
|
||||
planted = self.root.parent / "planted"
|
||||
planted.mkdir()
|
||||
marker = self.root.parent / "ran"
|
||||
fake = planted / "council-probe"
|
||||
fake.write_text(f"#!/bin/sh\n/usr/bin/touch '{marker}'\n", encoding="utf-8")
|
||||
fake.chmod(0o755)
|
||||
self.config.write_text(json.dumps({"notify": ["council-probe"]}), encoding="utf-8")
|
||||
self._send("s1", "send", "mayday", "fire")
|
||||
result = subprocess.run(
|
||||
[sys.executable, str(RADIO), "tool"],
|
||||
input=json.dumps({"session_id": "s2"}), capture_output=True, text=True,
|
||||
env={**self._env(None), "PATH": str(planted)}, check=False, timeout=30,
|
||||
)
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
self.assertIn("MAYDAY", result.stdout)
|
||||
self.assertFalse(marker.exists())
|
||||
|
||||
def test_the_hooks_skip_a_session_lock_another_process_holds(self):
|
||||
self._send("s1", "post", "board")
|
||||
lock = self.root / "radio-seen" / "s2.lock"
|
||||
|
||||
Reference in new issue
Block a user