feat(orchestrator): firewall view with signed settings changes (001 S6)

Requirement 001 S6: the hub gets a Firewall view of the Claude Code permission and sandbox settings. The operator signs each change with the passkey; a host settings writer (systemd path unit) applies only exact, signed changes to allowlisted settings files through O_NOFOLLOW directory and file descriptors, and a timer refreshes the view. Every signed text and every page sink refuses or marks hidden characters: Cc, Cf, Zl, Zp, every space but U+0020 and the Default_Ignorable set, with U+FE0E/U+FE0F allowed only after one of the 359 non-ASCII emoji bases of Unicode 16 (shared table, validated at import, the same pair rule on the page). Removal of a deny, ask or denyRead entry is exempt only as an exact single remove. The permission hook prints the hub's refusal reason, cleaned of hidden characters. Accepted MEDUSA false positives (independent review, operator pick): 38 this round, mainly the Unicode defence tables read as attack patterns, generic MM-SCAN-058 heuristics, WEB-FLASK-004 at view.py:213 (ints from the validated table via tojson), EXF26-TOOL-004 on the non-secret WebAuthn challenge, PRIV-SCAN-060 on the office-action shape check and PQC007 on a picker key.

🎯 Fix: 95 %
💥 Break: 3 %
💸 Cost: –
⏱️ Time: –
🛡️ Security: 100 %
🏆 Score: 92
🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 %

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-13 18:14:17 +00:00
1 parent 3418738993
commit 9742884308
54 files changed
+3920 -168

No files matched your search

+24 -3
View File
@@ -30,9 +30,9 @@ from __future__ import annotations
import argparse
import json
import re
import sys
import time
import urllib.error
import urllib.request
from pathlib import Path
@@ -51,7 +51,6 @@ DENIED = "The operator denied this in the Agent Orchestrator."
CHANGED = "staged tree changed since the preview"
UNBOUND = "the staged tree cannot be read, so the allow is not bound to it"
REASON_LIMIT = 2000
CONTROL = re.compile(r"[\x00-\x1f\x7f]")
FAILURES = (OSError, ValueError, staged_diff.DiffError)
@@ -99,7 +98,26 @@ def commit_diff(ask: dict, rules: Path | None) -> tuple[str | None, dict]:
def clean(text: str) -> str:
return CONTROL.sub("?", text.strip())[:REASON_LIMIT]
"""Returns:
text on one line for the terminal and the agent: every character
signing.unseen() names, a C0 or C1 control, a bidi or zero-width
character among them, shown as ?, but a selector signing.presented()
accepts; cut at REASON_LIMIT.
"""
stripped = text.strip()
return "".join("?" if signing.unseen(char) and not signing.presented(stripped, index) else char for index, char in enumerate(stripped))[:REASON_LIMIT]
def refusal(error: urllib.error.HTTPError) -> str:
"""Returns:
The reason the hub sent with an error status, on one line, or the
status text when its body cannot be read.
"""
try:
body = error.read().decode("utf-8", "replace")
except OSError:
body = ""
return clean(body or str(error.reason))
def bound(chosen: dict | None, ask: dict, pinned: str | None) -> dict | None:
@@ -194,6 +212,9 @@ def main() -> int:
answer = {"status": "pending"}
while answer["status"] == "pending" and (left := deadline - time.monotonic()) > 0:
answer = status(base, ask_id, min(left, POLL))
except urllib.error.HTTPError as error:
print(f"kvb-orchestrator: the hub answered {error.code}, Claude Code asks instead: {refusal(error)}", file=sys.stderr)
return 0
except (OSError, ValueError, KeyError, TypeError, AttributeError):
return 0
chosen = bound(decision(answer, signing.ask_item(ask_id, ask["tool"], ask["command"], ask["cwd"], ask["session"]), trust), ask, pinned)