Repository navigation
feat(positron): authenticate CommandEnvelope.source against session state - #1742
Merged
Merged
Conversation
…tate
A positron session multiplexes two principals over ONE socket — the
human at the surface and any AI observer perceiving that surface — so
`source` (not `peer_id`) is what distinguishes them. Until it is
authenticated, the confused-deputy clamp presumes an HONEST source
(the tracked precondition in continuum-core `routing/auth_policy.rs`):
a command could stamp `source: Observer { observer_id }` for any id,
registered or not, spoofing another observer's audit id or claiming
observer authority it never established.
Close the shippable leg now, using only session-local state — no
socket/GH-auth handshake required: `Connection::handle_command` verifies
the declared `Observer` source names an observer registered on THIS
connection via a prior `Observe` before the command reaches the
dispatcher. A source it can prove is forged never executes — the forgery
is answered with one loud `CommandFailed` naming the id, not silently
clamped (per [[fallbacks-are-illegal-fail-loud]]). This also makes the
`observer_id` that drives downstream authorization + audit verifiable
provenance rather than an unchecked client claim.
The `Human` leg honestly still awaits the socket/GH-auth handshake (the
socket IS the human; nothing session-local to check it against) —
harmless today because both sources resolve to the same Provisional
ceiling; this guard protects the divergence the moment that elevates.
Tests: forged unregistered-observer command → loud CommandFailed naming
the id + NEVER reaches the dispatcher; registered observer (after
Observe) → dispatches normally.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…est + tripwire Adversarial review of PR #1742 (REQUEST CHANGES). All defects addressed: - MAJOR #1 (scope accuracy): the doc + framing overstated "never executes." Today's live WS transport routes commands through the RPC path (ipc/ws.rs::dispatch_command), which hardcodes CallerIdentity:: ws(nil) and never populates `source` — so this guard is not on that live vector yet. It closes the vector for the transport that WILL route commands through the session (UDS / airc-sourced). Doc comment on handle_command now states this build-ahead scope explicitly (same shape as ExecutorDispatch being wired but not yet reached on WS). - MAJOR #2 (test wiring): both prior tests called handle_command directly, not the production entry Connection::handle. Added forged_observer_command_is_rejected_through_the_handle_entry_point — sends an unregistered-Observer command through handle() and asserts CommandFailed + call_count==0. Pins the guard to the real routing. - MINOR #3 (Human tripwire): added a SECURITY tripwire comment on the `Human => None` arm tying it to the Ws==Provisional precondition (owned by continuum-core auth_policy.rs, outside this crate) and task #29. The moment #29 elevates the Ws ceiling, this passthrough becomes a live escalation — the comment forces that PR to bind/verify the human principal here. - NIT #5 (over-rejection): documented that Observe-before-Command is intentional (an unestablished principal IS forged; it's what makes the observer_id verifiable) — a write-only actuator is a deliberate protocol change, not a bug to patch by relaxing the guard. Tests: 12 passed (connection::). cargo check clean. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
Contributor
Author
Adversarial review addressed (verdict was REQUEST CHANGES)Pushed
|
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.
What
Closes the shippable leg of the positron source-auth work — the security follow-up flagged as the tracked precondition for the confused-deputy clamp in continuum-core
routing/auth_policy.rs.A positron session multiplexes two principals over ONE socket: the human at the surface, and any AI observer perceiving that surface. Both ride the same anonymous socket (nil
peer_id, pre-auth), sopeer_idcan't distinguish them — thesourcedoes. Untilsourceis authenticated, the clamp presumes an honest source: a command could stampsource: Observer { observer_id }for any id — registered or not — spoofing another observer's audit id or claiming observer authority it never established.The fix (session-local, no handshake required)
Connection::handle_commandnow verifies the declaredObserversource names an observer registered on THIS connection (via a priorObserve) before the command reaches the dispatcher. A source it can prove is forged never executes — the forgery is answered with one loudCommandFailednaming the id, not silently clamped (per[[fallbacks-are-illegal-fail-loud]]). This also upgrades theobserver_idthat drives downstream authorization + audit from an unchecked client claim to verifiable provenance.Honest scope
The
Humanleg still awaits the socket/GH-auth handshake — on a positron connection the socket is the human, so there's nothing session-local to check it against. This is harmless today because bothHumanandObserverresolve to the sameProvisionaltrust ceiling; the guard protects the divergence the moment that ceiling elevates. Documented inline onreject_forged_source.Surface
Purely additive: one private method + one import + two tests in
continuum-positron/src/connection.rs. No public API changed → continuum-core unaffected.Tests
command_with_unregistered_observer_source_is_rejected_loud— forged unregistered-observer command → loudCommandFailednaming the id + NEVER reaches the dispatcher.command_with_registered_observer_source_passes_after_observe— registered observer (afterObserve) → dispatches normally (no over-rejection).Validated:
cargo test -p continuum-positron --lib connection::→ 11 passed.cargo check -p continuum-positronclean.🤖 Generated with Claude Code