Repository navigation
fix(session-control): authorize a child's private-store binding on caller authority - #12185
chenmingwei23 wants to merge 1 commit into
Conversation
…ller authority Selecting an agent is a caller-supplied string, so it cannot authorize the private V2 store that agent names. create_session derived the child's store from the selection, so an unbound caller minted a worker inside any member's private memory by naming that member's agent, then read that memory through the child's turns. The population is wider than the owner clicking in the dashboard: a cron slot, and anything a fenced caller created, all name agents. Authorize once, at the single point where every branch of agent resolution has produced its final route, before the slot is allocated. Two admissions: the store is the caller's own, read from its protected execution record, or the caller is not ownership-fenced. Slot metadata authorizes nothing. The refusal population is the one the ownership fence already distrusts, and the owner's dispatch capability is unchanged, so no shipped capability is removed. The fence verdict is carried from the HTTP gate as the other routes already carry it. Closes kirodotdev#11613
c8e0374 to
cd1f372
Compare
First Principles Review (Fable 5, fork) —
|
Design Review (Fable 5, fork) —
|
Opus 4.8 Review (fork) —
|
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
|
Superseded by #12467, which carries the identical commit Reason: the Nothing about the change itself moved. Closing in favour of #12467. The fork branch is left in place. |
Problem / Motivation
create_sessionderived the child's memory route from the selected agent. Selectingan agent is a caller-supplied string, so a caller with no private-memory record of
its own could mint a functioning worker inside a crew member's private V2 store by
naming that member's agent, and then read that memory through the child's turns.
The population that reached it was wider than an owner clicking in the dashboard. A
cron slot has no private record, and neither does anything a fenced caller created,
and both can name an agent.
#11593fenced the birth pin to the store thedelegation gate had cleared; the gate that produced that value was later removed by
the one-SQLite-store refactor, so nothing was left checking the caller at all -- while
the refusal table in
docs/system-specs/modules/session-control.mdstill documentedmemory_delegation_deniedfor exactly this case.Why it matters
A member's private store is meant to be reachable only by that member. Reaching it
needed no credential, no race and no unusual timing: name the agent, then read the
child. A cron slot runs while nobody is watching, and a created child inherits its
creator's agent, so the reach survived a hop the ownership fence exists to catch.
What changed
One authorization, at the single point where every branch of agent resolution has
already produced the child's final route, and before the slot is allocated. Placing
it per branch is what left the surface open: the explicit member selection, the
inherited caller execution and the caller-agent fallback all reach a member store,
so a check on one of them leaves the others.
A private member store is now reachable on two authorities and no others:
same-store worker. The record is the only admissible input, because
slot.agentand
slot.memory_storeare metadata a later write can change, and the selectionitself is caller-supplied, so deriving authority from either lets the request
authorize itself;
session.
Refused is the population
_caller_is_ownership_fencedalready treats as untrusted:a cron slot, a member DM slot naming a peer member's agent, and anything either of
them created. The refusal reuses the existing
memory_delegation_denied403 with afixed message that names neither the store nor the member, so it cannot confirm a
guessed agent name. An app-token caller never reaches the route and an app-scoped one
cannot create at all, so the fence covers the whole remaining population.
The owner's dispatch capability is unchanged, so no shipped capability is removed and
no RFC is required. The nested-conductor design also survives: a member-created
worker is itself fenced but is on its own store, so the own-store authority still
admits its same-store children.
The fence verdict is carried in from the HTTP gate as
caller_fenced, exactly as theother session-control routes already carry
precomputed_ownership_fenced, because theinline predicate re-derives member status from the mutable config record and this
coroutine suspends many times before the check. It is only ever read as a refusal, so
a record that stops saying "member" in that window can turn a refusal into an
admission the owner already holds, never the reverse.
The spec's refusal row named the removed gate; it now states the two admissions, and a
new section records the model so the next reader does not reconstruct it from
#11018.Tests
test/test_member_session_control.py::TestPrivateStoreCallerIsolation, 10 cases,both directions. Refused: a cron slot naming a member's agent; the second door on the
same store, where the child inherits
caller_slot.agentand noagentargument ispassed; an agent-created child; a member naming a peer; and a carried fence verdict
deciding on its own with the config read monkeypatched to fail the test if reached.
Admitted: an owner's dashboard slot, a member's same-store worker by inheritance and
by explicit selection, a fenced caller's ordinary global-store worker, and a fenced
member-created worker dispatching its own same-store child. Each refusal also asserts
nothing was published (
creator_slot_count == 0).Mutation-checked in both directions, six mutations, all killed, each asserted to have
applied and run against a green unmutated baseline. Weakening the refusal (disable it;
key it on the explicit-selection branch only; drop the store comparison; ignore the
carried verdict) reddens the block tests and leaves the allow tests green. Weakening
the admission (remove the same-store authority; stop carrying the verdict at the
route) reddens the allow tests and leaves the block tests green.
TestMemberChildExecutionContext::test_explicit_target_member_captures_selected_routewas parametrized over both caller classes while nothing enforced the refusal half. It
is narrowed to the global caller, which is the half the spec documents as admitted;
the private caller's case is now among the refusals above.
323 tests pass across
test_member_session_control.py,test_cron_session_control.py,test_session_control.pyandtest_session_control_member_gate.py. Black, flake8,isort, brand-name, comment-history, docs-lint and subprocess-encoding gates pass.
Pattern harvest
A caller-supplied string cannot be an authorization input, however faithfully it is
resolved. The selection here was resolved correctly every time -- through config, under
the right locks, into a valid execution context -- and the store it produced was still
chosen by the caller. The record is the authority; the selection is a request.
An authorization placed per branch is an authorization with as many holes as the
branches nobody enumerated. Three branches reached a private store and one of them was
fenced, which reads as covered. The fix is one check on the value all of them produce.
Rule candidate: when several branches converge on one privileged value, authorize the
converged value at the single point every branch has already reached, not each branch.
A per-branch check is only as complete as the branch enumeration, and a fenced branch
among unfenced siblings reads as covered while the siblings stay open.
Rule candidate: an input the caller supplies can never be the authority for reaching
what that input names, even when it is resolved correctly. Derive authority from a
record the caller cannot write; treat the caller's value as a request against it.
Closes #11613