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
@@ -32,6 +32,8 @@ Environment:
|
||||
its commands outside the sandbox; a Docker daemon the sandbox can
|
||||
reach still writes it. Without a config file every command exits 0 and does
|
||||
nothing.
|
||||
PATH: filtered to the directories hookpath.py trusts before any command
|
||||
runs, the config's commands included.
|
||||
|
||||
Config keys, all required: disk, thresholds_gb {warn, stop, critical},
|
||||
projection_minutes, interval_seconds, cache_interval_seconds, heavy_commands,
|
||||
@@ -73,7 +75,8 @@ def sibling(name: str) -> ModuleType:
|
||||
|
||||
|
||||
nofollow = sibling("nofollow")
|
||||
ROOT = Path(os.environ.get("AGENTS_COUNCIL_ROOT", "/tmp/agents-council"))
|
||||
hookpath = sibling("hookpath")
|
||||
ROOT =Path(os.environ.get("AGENTS_COUNCIL_ROOT", "/tmp/agents-council"))
|
||||
CONFIG = Path(
|
||||
os.environ.get(
|
||||
"AGENTS_COUNCIL_CONFIG",
|
||||
@@ -209,7 +212,7 @@ def notify(cfg: dict, text: str) -> None:
|
||||
|
||||
def spawn_cleanup(mode: str) -> None:
|
||||
subprocess.Popen(
|
||||
[sys.executable, str(Path(__file__).resolve()), "cleanup", mode],
|
||||
[sys.executable, "-I", str(Path(__file__).resolve()), "cleanup", mode],
|
||||
stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||
start_new_session=True,
|
||||
)
|
||||
@@ -523,6 +526,7 @@ def main() -> int:
|
||||
mode.add_argument("--full", action="store_true")
|
||||
sub.add_parser("status")
|
||||
args = parser.parse_args()
|
||||
os.environ["PATH"] = hookpath.trusted(os.environ.get("PATH", ""))
|
||||
refused = guard_root(hook=args.cmd in ("watch", "block"))
|
||||
if refused is not None:
|
||||
return refused
|
||||
|
||||
Reference in new issue
Block a user