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>
68 lines
2.9 KiB
Python
68 lines
2.9 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
import subprocess
|
|
import unittest
|
|
|
|
from hub_support import HUB
|
|
|
|
PASSKEY = HUB / "templates" / "page-passkey.js"
|
|
PROBE = """
|
|
const source = require("fs").readFileSync(process.argv[1], "utf8");
|
|
const toasts = [];
|
|
const gates = [];
|
|
let asked = 0;
|
|
let served = 0;
|
|
const window = {location: {hostname: "localhost", port: "8737", pathname: "/", hash: ""}};
|
|
const navigator = {credentials: {get: () => {
|
|
asked += 1;
|
|
return new Promise((resolve, reject) => gates.push({resolve, reject}));
|
|
}}};
|
|
const sendJson = async () => {
|
|
served += 1;
|
|
return {ok: true, data: {payload: {nonce: served}, challenge: "AAAA", credentials: ["AAAA"]}};
|
|
};
|
|
const toast = (title) => toasts.push(title);
|
|
const bytes = new Uint8Array([1]).buffer;
|
|
const credential = {rawId: bytes, response: {clientDataJSON: bytes, authenticatorData: bytes, signature: bytes}};
|
|
const P = new Function("window", "navigator", "sendJson", "toast", "fail", "h", "promptText", "document", `${source}\\nreturn {signedProof};`)(window, navigator, sendJson, toast, () => [], () => ({remove: () => {}}), (label) => label, {body: {append: () => {}}});
|
|
const tick = () => new Promise((resolve) => setImmediate(resolve));
|
|
const nonce = (signed) => (signed ? signed.proof.payload.nonce : null);
|
|
(async () => {
|
|
const first = P.signedProof("/api/board/sign", {action: "resume"}, "Resume");
|
|
const second = P.signedProof("/api/board/sign", {action: "resume"}, "Resume");
|
|
await tick();
|
|
const open = {asked, served, toasts: [...toasts]};
|
|
gates.splice(0).forEach((gate) => gate.resolve(credential));
|
|
const both = [nonce(await first), nonce(await second)];
|
|
const canceled = P.signedProof("/api/board/sign", {action: "drain"}, "Drain");
|
|
await tick();
|
|
gates.splice(0).forEach((gate) => gate.reject(new Error("canceled")));
|
|
const dropped = nonce(await canceled);
|
|
const after = P.signedProof("/api/board/sign", {action: "suspend"}, "Suspend");
|
|
await tick();
|
|
gates.splice(0).forEach((gate) => gate.resolve(credential));
|
|
console.log(JSON.stringify({open, both, canceled: dropped, after: nonce(await after), asked, toasts}));
|
|
})();
|
|
"""
|
|
|
|
|
|
class TestPasskeyPage(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
done = subprocess.run(["node", "-e", PROBE, str(PASSKEY)], capture_output=True, text=True, timeout=60, check=True)
|
|
cls.data = json.loads(done.stdout)
|
|
|
|
def test_a_second_signature_while_one_is_open_asks_no_passkey_and_sends_nothing(self):
|
|
self.assertEqual(self.data["open"], {"asked": 1, "served": 1, "toasts": ["Resume: not signed"]})
|
|
self.assertEqual(self.data["both"], [1, None])
|
|
|
|
def test_a_canceled_signature_frees_the_next_one(self):
|
|
self.assertIsNone(self.data["canceled"])
|
|
self.assertEqual((self.data["after"], self.data["asked"]), (3, 3))
|
|
self.assertEqual(self.data["toasts"], ["Resume: not signed", "Drain: not signed"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|