Repository navigation
feat(agent route): answer only Claude Code and Codex (ADR-0013 step 3) - #113
Merged
Merged
Conversation
The agent key route now answers, inside the agent account, only the agent's tool with the code hash the owner approved in Settings, started by Claude Code or Codex as validated by macOS (Developer ID, teams Q6L2SF6YDW and 2DC432GLL2). Both must have hardened runtime, be neither debuggable nor debugged, and name neither allow-dyld-environment- variables nor get-task-allow in their entitlements. Claude Code's disabled library validation is accepted, as the owner decided. Everything is read from the kernel's record of the running programs, never from their files, since the ADR-0013 spike showed the Security framework's checks are refused under the App Sandbox while these work: csops_audittoken through the connection's audit token for the tool, sysctl(KERN_PROC_PID) for its parent (kinfo_proc size and fields checked; proc_pidinfo is refused for other accounts) and csops for the parent, then a re-check that the tool and its parent are unchanged. Anything else is closed without a reply, as a wrong account is. - agent_route.rs: ProgramIdentity, ProgramPolicy, judge_programs on every platform; check_program and the kernel readers on a Mac; the listener runs the check after the account check. ProgramCheck::Off exists only in debug builds (ENOTE_DEV_AGENT_ANY_PROGRAM, tests). - Settings: "The agent tool's code hash" (the CDHash line), kept in settings.json; Start refuses without it; changing it ends a grant. The Start dialog says Claude Code or Codex. - agent-keys-setup.sh prints the tool's code hash and refuses a tool not signed with hardened runtime; it no longer prints the Claude desktop app's chat config, which isn't on the list. - Tests: every branch of the decision; the kernel readers against a running /bin/sleep; on a real socket, Apple's nc as the tool and bash as its starter, answered when both are listed and closed without a reply for the real list, a wrong tool hash, or a direct connection. - Docs: ADR-0013 As built, the guide, the security model, AGENTS.md, CONTEXT.md. Fictional data and stand-in programs only; not yet run from Claude Code or Codex in a real agent account, nor in a Developer ID-signed build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ADR-0013 step 3: the agent key route (ADR-0012) now answers only the agent's tool,
enote-agent-keys, with the code hash the owner approved, when Claude Code or Codex started it. Before this, any program running in the agent account could use the route.What it checks
Each connection gets these checks after the existing account (uid) check. Any failure closes the connection without a reply, the same way a wrong account is handled.
ALLOWED_STARTERS, with identity, team and a Developer ID category, as macOS validated them:com.anthropic.claude-code, teamQ6L2SF6YDWcodex, team2DC432GLL2allow-dyld-environment-variablesnorget-task-allow.Everything is read from the kernel's record of the running programs, never from their files:
csops_audittoken, through the socket'sLOCAL_PEERTOKEN, for the tool;sysctl(KERN_PROC_PID)for its parent, with thekinfo_procsize andp_pidchecked;csopsfor the parent.The ADR-0013 spike (#112) found that the Security framework's checks are refused under the App Sandbox, and so is
proc_pidinfofor another account.Choices made
disable-library-validationis accepted, as you decided in the spike. Only the two entitlements that let outside code in are refused.scripts/agent-keys-setup.shprints it as theCDHash=line, and refuses a tool that wasn't signed with hardened runtime. You paste that line into Settings → "The agent tool's code hash".not_set_up).ProgramCheck::Offexists only in debug builds. It is used by tests, and byENOTE_DEV_AGENT_ANY_PROGRAM=1for trying the route in one account.Tests
judge_programs, using made-up identities./bin/sleep.ncstands in for the tool andbashfor its starter:./scripts/check.shpassed locally in full. That includes clippy, cargo deny, the secret scan, the network-source check, the WebView build and all 38 agent route tests.Not verified
Fictional data and stand-in programs only.
🤖 Generated with Claude Code