Repository navigation
fix(identity): one resolver ladder, pid mapping records its tenants - #14357
Conversation
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 completed its review of This comment is updated in place on each push. Review detailsFINDING -- src/kiro_crew/dashboard/token_auth.py:2042 -- a shared False positive or not applicable? A repository writer can comment: |
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify no other internal unix-socket sender declares Suggestions
[DESIGN-REVIEWED] a168df5 Description read[DESCRIPTION-READ] 81587141d1b2a93968e4924f8bd9863582d2c9c435a1994bcc0ea6fb8bc065ff That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Fable 5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS
Not justified as shipped
What this change shipsInventory (10 items) — 8 justifiedIntent: FIX — stop a shared kiro-cli pid misattributing one session's internal calls to another (reproduced 403 on main; refs #14355/#14484).
[FIRST-PRINCIPLES-REVIEWED] a168df5 Description read[DESCRIPTION-READ] 73e32a571dbb8ffc5a4bae8d1df48a803ad0e2756ce07df174399cdbe6c18bc4 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5 Review — ✅ no blocking findingsReviewed Review detailsNot blocking — one advisory issue: the new pid-mapping rung's fail-closed degrade turns a stale recycled mapping in a tokenless caller's ancestry into a permanent FINDING — src/kiro_crew/mcp_caller.py:394 — [OPUS-REVIEWED] a168df5 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
fef633b to
b3cd10b
Compare
b3cd10b to
fc5fb5f
Compare
fc5fb5f to
b86ff49
Compare
81a85c2 to
8f7b59d
Compare
8f7b59d to
fbb8f5e
Compare
fbb8f5e to
13284b8
Compare
13284b8 to
5b6c9a0
Compare
UX Review (Fable 5) — ⏭️ skippedRevision |
|
/ai-review override gpt 38f59dc: Reading a sibling's /proc//environ requires PTRACE_MODE_READ, which already grants /proc//mem and ptrace on that process and so every secret in it, meaning this token is not the weakest link and the standing stronger-capability test is met; the arm's bytes are unchanged and GPT cleared them on b86ff49, 81a85c2, fbb8f5e and a42640b; and at cap=1 only a subagent companion shares a runtime, which is the same session's own trust context. |
Human judgment recorded@chenmingwei23 marked the gpt AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
Identity came from the pid, and a pid names a PROCESS. One kiro-cli process hosts many ACP sessions, so on a shared runtime the mapping held whichever key was published last: four client-side resolver copies attributed MCP calls to a co-tenant, and the server side refused a legitimate co-tenant with 403. The source of identity moves to the per-session token. The pid mapping stays as a fallback and now records which sessions share the pid, inside the same MAC, so a reader that resolves its own identity refuses instead of guessing and a reader that verifies someone else's checks membership plus a token. The four copies collapse into one ladder. On a shared pid, membership is necessary but not sufficient: the roster is agent-readable, so a token naming exactly the declared key is required, and the requirement is keyed on the pid demonstrably hosting several sessions rather than on the arm that discovered the need. Every internal sender that declares a key attaches that token, so the demand admits the callers it was written for instead of refusing them. The mapping files sit in an agent-writable directory, so neither their absence nor a failed signature is evidence of anything. A mapping whose MAC does not verify, and an absence the live session manager contradicts, both demand the token. A proven recycle does not -- that one is attested knowledge that the pid moved on, and routine housekeeping produces it constantly -- and neither does an absence no authority contradicts, which is what keeps a warm-pool runtime, a cron script and a pooled backend working. The tenant set counts SESSIONS only. The manager's snapshot appends a row per companion runtime carrying display text, and a subagent runtime often repeats the pid of a session it serves, which would record two tenants for a pid hosting one and refuse a session that is not shared. Behaviour on a 1:1 runtime is unchanged -- same bytes on disk, same ladder order, same answers. The pid-reader ratchet moves 161 -> 148 in this commit, because the ratchet asserts EQUALITY and this change deletes 13 per-session pid readers: the four ancestor-walk copies collapse into one ladder and the libproc/ps helpers go. Measured on this tree rather than taken from the failure text -- 148 passes and restoring 161 reddens exactly that one test.
Problem / Motivation
Goal: make a process's session identity come from its own per-session token, and make the pid mapping record which sessions share a pid, so a shared runtime stops misattributing one session's calls to another.
session_pid_<pid>.txtmaps a pid to one session key, but one kiro-cli process hosts several ACP sessions (aspawn_runsub-agent runs on its parent's runtime;workflows/agent_pool.pyworkers share one). Every reader of that mapping answers with whichever session published last. That is a wrong answer, not a refusal, so the caller cannot tell.One reader is an authorization check.
dashboard/token_auth.py::_verify_unix_peerdenies when the mapped key differs from the declaredX-Session-Key, so on a shared pid the co-tenant is denied while declaring its own correct key. Reproduced on unmodified main: founder -> 200, co-tenant -> 403peer_session_mismatch. Four client-side resolvers (mcp_caller,mcp_core,mcp_shared,peer_resolve) end in the same walk and return a co-tenant's key.Why it matters
A 403'd session loses every session-keyed internal call:
learn_add, cron management, ledger writes, callback delivery. Where the walk succeeds instead, a sub-agent's memory write, audit row or tool-policy lookup is silently charged to its parent.Not a goal
/proc/<pid>/mem, so the token is not the weakest link. Tracked for Wave 3 (RUNTIME_TENANCYclaim binding); the GPT finding on this head was overridden by the project owner on that basis.What changed (motivation -> approach -> change)
session_pid_sig.publish_session_pidtenants=<n>+ onetenant=<key>line each, under the existing MAC; written only above one sessiontoken_auth._verify_unix_peerX-Session-Tokenverifying to the declared key on a shared pid; 1:1 path unchanged. With no mapping on disk, the live session manager's own key set decides: a declared key the manager does not host needs a token, and the degrade to today's semantics happens only when the manager knows nothingps/libprochelpersmcp_caller.resolve_own_identityoverplatform_compat.get_ppid_FROM_ENV_CACHEmcp_tools/browser.py,mcp_computer.pysession_token_header()so they keep working on a shared pidOne pid, N sessions, one key recorded, so readers guess. Recording which sessions share the pid removes the guess. The MAC stops an agent adding itself to a signed pid's membership; every co-tenant can still read the list, so membership alone is not enough to be a named session. On a shared pid the auth path also requires the per-session token, which is MAC'd under the agent-unreadable SEL trust root and already sent by every caller.
Two questions get two answers. Resolving your own identity from a shared pid has nothing to go on, so it refuses and says why. Verifying a declared identity checks membership plus token, so a legitimate co-tenant passes and a key the pid does not host is still denied. Absence of the record stays unknown, never "not shared", and a size-bounded mapping reports the true count so a truncated set is never read as complete.
The four client-side walks collapse into one ladder so a fifth copy cannot land silently;
test_identity_topology.pyregisters the call sites. The process-lifetime memo sits below every session-scoped rung because a rekey rewrites the token's mapping while the token bytes survive, so any memo in front of the token would answer the pre-rekey session for the life of the process.Backwards compatibility
Compatible: a 1:1 pid produces byte-identical mapping files and the auth path is unchanged for it; a reader that does not understand the tenant section refuses rather than mis-parses.
Tests
test_identity_topology.pyadds a shared-runtime topology: all four resolvers refuse a co-tenant's key with the reason logged and name their own session from their own token.test_dashboard_peer_auth.pypins the three auth outcomes (co-tenant verified, foreign key 403, truncated membership degrades).test_session_pid_sig.py,test_resolve_session_key.py,test_mcp_browser_tool.py,test_mcp_computer.pyandtest_messaging_identity.pyare repointed to the new behaviour. Mutations for each guard are recorded in the review thread; every one reddens its named test.The pid-reader ratchet moves 161 -> 148 in this commit: this PR removes 13 per-session pid readers (the four resolver walks collapsed into one, and the libproc/ps helpers deleted). The count is measured on this tree, not copied from the failure text.
Manual verification
Two sessions on one process on this branch: founder and co-tenant both 200; a third key not hosted by the pid 403. The recycled-pid ancestor case was reproduced and is deferred to #14646.
Screenshots / video
N/A -- no user-visible UI change.
Related Issues
Refs #14355, #14484, #14646
Pattern harvest
Rule candidate: review-prompt -- a signature proves who wrote a list, never which member of it is speaking; a membership check on a shared identity must be paired with a per-member credential.
Checklist
docs/system-specs/modules/dashboard-token-auth.md,session.md)