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:
1 parent
3418738993
commit
9742884308
54 files changed
+3920
-168
No files matched your search
@@ -6,7 +6,7 @@ from .denying import request_status, request_words, requester_of
|
||||
from .errors import Conflict, Missing, ToolError
|
||||
from .fields import WAIT_CAP, bounded, decode, expect, field, seconds
|
||||
from .records import iso_epoch
|
||||
from .rules import rule_fields, rule_matches, signed_fields, subject_of
|
||||
from .rules import EVERY_AGENT, rule_fields, rule_matches, signed_fields, subject_of
|
||||
from .signed import signing
|
||||
|
||||
# Trip-wire: MCP carries no caller identity, so an agent may name itself anew for each request; AGENT_CAP only spreads the queue, TOTAL_CAP is the bound.
|
||||
@@ -33,7 +33,7 @@ class Requesting:
|
||||
def rule_request(self, arguments: dict) -> dict:
|
||||
expect(arguments, (*RULE_FIELDS, "agent", "why"))
|
||||
now = time.time()
|
||||
fields = rule_fields(arguments, now)
|
||||
fields = {name: value for name, value in rule_fields(arguments, EVERY_AGENT, now).items() if name in RULE_FIELDS}
|
||||
if fields["kind"] == "decision" and fields["scope"] != "*":
|
||||
raise ToolError("a decision rule takes scope *, as the rules form does")
|
||||
name = field(arguments, "agent").strip()
|
||||
@@ -71,7 +71,7 @@ class Requesting:
|
||||
rule = {**{key: record[key] for key in RULE_FIELDS}, "enabled": True, "proof": {"payload": payload, "assertion": None}}
|
||||
ledger = {"ask": self.asks, "review": self.reviews, "decision": self.decisions}[kind_name]
|
||||
since = now - RECENT_DAYS * 86400
|
||||
subjects = [subject_of(kind_name, entry) for entry in ledger.listed() if created_of(entry) >= since]
|
||||
subjects = [subject_of(kind_name, entry, self.deciders(kind_name, entry)) for entry in ledger.listed() if created_of(entry) >= since]
|
||||
return {"matched": sum(rule_matches(rule, kind_name, subject, now) for subject in subjects), "total": len(subjects), "days": RECENT_DAYS}
|
||||
|
||||
def request_items(self, base: dict, now: float, claims: list[dict]) -> list[dict]:
|
||||
@@ -95,7 +95,7 @@ class Requesting:
|
||||
|
||||
def sign_request(self, request_id: str) -> dict:
|
||||
record = self.pending_request(request_id)
|
||||
return {**self.rule_offer(rule_fields(record, time.time())), "sign": True}
|
||||
return {**self.rule_offer(rule_fields(record, EVERY_AGENT, time.time())), "sign": True}
|
||||
|
||||
def accept_request(self, request_id: str, body: bytes) -> dict:
|
||||
payload = decode(body)
|
||||
@@ -106,9 +106,8 @@ class Requesting:
|
||||
fields = signed_fields(rule, now)
|
||||
if [fields[key] for key in RULE_FIELDS] != [record[key] for key in RULE_FIELDS]:
|
||||
raise ToolError("the signed rule must be exactly the requested one")
|
||||
if self.rules.get(rule["id"]) is not None:
|
||||
raise Conflict({"id": rule["id"], "status": "exists"})
|
||||
proof = self.proven_rule(rule, payload["assertion"])
|
||||
self.offered(rule, now)
|
||||
decided, changed = self.rule_requests.decide(request_id, {"status": "accepted", "rule": rule["id"]})
|
||||
if not changed:
|
||||
raise Conflict(request_state(decided, now))
|
||||
|
||||
Reference in new issue
Block a user