From c158321b40424b5eebedebd72f93b6852ab1ee09 Mon Sep 17 00:00:00 2001 From: Angus Kola Date: Wed, 4 Nov 2026 14:43:22 -0500 Subject: [PATCH] Reject peer-originated Remote relay membership --- remote.md | 12 +++++++++ remote/implementation.md | 44 +++++++++++++------------------- remote/src/connection_ui_test.go | 19 ++++++++++++++ remote/src/session.go | 2 +- remote/src/session_test.go | 8 ++++++ remote/src/transport.go | 3 +++ remote/src/transport_test.go | 1 + 7 files changed, 62 insertions(+), 27 deletions(-) diff --git a/remote.md b/remote.md index efe5ec3..59de25e 100644 --- a/remote.md +++ b/remote.md @@ -206,6 +206,18 @@ Production output observation, delivery-time arbitration, remote cancellation ownership and audible speech remain pending. No installed or active reader was replaced; Phase B/C and all live release gates remain open. +Review corrections (2026-11-04): pending reader actions now emit an +`remote.revoked` event on expiry or revocation, carrying the action token instead +of a lease token. Both SDKs validate exactly one identity, and setup workflows +retire on the notification. Relay `channel_joined` messages with a peer origin +are rejected at both transport and membership boundaries. Regression tests +reproduced both previous behaviors. The reader host/wire race suites (host: +143 seconds), full Remote race suite, focused application race checks, shared +interaction/Braille/preferences race suites, focused vet and Tentacles +`make check` passed. No physical-input, audible-speech, physical-Braille or +live-interoperability acceptance was performed. This does not complete any +release gate. + ## 1. Intended result and recommended approach Build a native Go Tentacle named **Remote**, with package ID `remote`, in this diff --git a/remote/implementation.md b/remote/implementation.md index dda043d..186fb60 100644 --- a/remote/implementation.md +++ b/remote/implementation.md @@ -34,8 +34,8 @@ are relative to the adjacent `cthulhu` checkout. | Go SDK | `ServeSession` and `SessionClient` provide 1.1 calls/events; legacy Serve remains unchanged. Real-process tests include blocked pipes and command concurrency. | | Python SDK | `serve(session_client=...)` provides the same 1.1 lifecycle contract and conformance fixtures as Go, with a cancellable nonblocking pipe transport. | | Installation | Installer, registry, discovery-to-package checks, local launch and command host now carry 1.1 install grants. Grants do not create session consent. | -| Updates/access | Install/update confirmations disclose grant direction and fresh local approval; disable/failure cancels leases. Updates revoke access before download, including failed preparation. Core consent and I38lock/XTerm policy cancellation now exist; physical-source acceptance, command registration and desktop owners remain pending. | -| Secret controls | Transient entries now support `secret: true`, with masked editing/speech/Braille, copy/cut denial and no values on cancellation. Persistent preference pages reject secrets. Private Xorg/SDK tests cover this prerequisite; a Remote connection UI, audible speech and physical Braille acceptance remain pending. See [the contract](../../cthulhu/docs/tentacle-secret-entries.md). | +| Updates/access | Install/update confirmations disclose grant direction and fresh local approval; disable/failure cancels leases. Updates revoke access before download, including failed preparation. Core consent and I38lock/XTerm policy cancellation now exist; physical-source acceptance and desktop owners remain pending. | +| Secret controls | Transient entries now support `secret: true`, with masked editing/speech/Braille, copy/cut denial and no values on cancellation. Persistent preference pages reject secrets. Private Xorg/SDK tests cover this prerequisite; the source command uses these controls; audible speech and physical Braille acceptance remain pending. See [the contract](../../cthulhu/docs/tentacle-secret-entries.md). | | Input | `internal/platform/xorg/listener.go` uses XRecord observation. That does not consume desktop keys. A private prototype now demonstrates exclusive capture and helper EOF/watchdog cleanup; production ownership, trusted origin and physical collisions remain unresolved. See [the feasibility record](../../cthulhu/docs/testing/remote-input-feasibility.md). | | Braille | `internal/braille/client.go` writes text/overlay dots through a helper. Shared viewport/cell-mask feasibility tests now demonstrate translated virtual cells and independent routing without a physical display. Virtual table/cursor policy, helper IPC and raw receiving remain open. See [the evidence](../../cthulhu/docs/testing/remote-braille-feasibility.md). | @@ -54,28 +54,19 @@ must never mint consent. table/cursor policy and implement isolated helper integration. These remaining feasibility gates are not assumptions established by the relay library. 2. The [protocol 1.1 lifecycle foundation](../../cthulhu/docs/tentacle-sessions.md) - now exists through both SDKs and installation. The reader's - [authorization increment](../../cthulhu/docs/tentacle-remote-authorization.md) - adds core consent, policy-bound production managers, I38lock/XTerm cancellation - and separate XI2 sensitive forms. Private tests establish XTEST rejection; - successful physical-source approval is still unverified. Register the - connection command and complete typed desktop operations; no child request - may create approval. The core consent procedure remains unregistered. -3. Use the secret-entry support and [secure storage](storage.md) for host-issued - connection, certificate-review and explicit saved-key actions. The - [library coordinator](lifecycle.md) now connects public SDK lifecycle events - and lease calls to relay cancellation and ordered close. Integrate it with - production local consent and UI; it currently has private fixture callers - only, discards desktop payloads and never retries or resumes automatically. - [Certificate and saved-key form handlers](security-ui.md) now provide explicit - certificate inspection, Copy/Trust once/Cancel and masked Remember/Forget - workflows, but have no production wiring until the reader can verify local - input origin. - The [connection-library workflow](connection-ui.md) now combines these forms - with Connect, explicit saved-key loading, status and epoch-scoped Disconnect. - It cancels pending setup/inspection on lifecycle loss and has a separate SDK - process fixture. Endpoint/role selection, persistent-pin UI, verified local - input origin and all production registration remain pending. + exists through both SDKs and installation. The reader's + [authorization implementation](../../cthulhu/docs/tentacle-remote-authorization.md) + provides core consent, policy-bound production managers, I38lock/XTerm + cancellation and XI2 sensitive forms. The source command is registered and + requests consent for its own process session. Private tests establish XTEST + rejection; successful physical-source approval remains unverified. +3. The [source command](command.md) combines endpoint/role selection, + [secure storage](storage.md), certificate inspection, explicit Trust once and + persistent pins, masked key entry, Remember/Forget and status/Disconnect. + The [coordinator](lifecycle.md) joins reader leases and revocation to relay + cancellation and bounded speech queues. Pending approval expiry now emits + revocation too, cancelling setup before a lease opens. Verify these workflows + with physical local input; synthetic submissions do not establish that gate. 4. Add policy-resolved output observation and remote presentation with origin ownership, secure-input/lock/handoff exclusion and local status priority. 5. Complete keyboard recovery, explicit clipboard transfer and virtual/raw @@ -140,8 +131,9 @@ actual NVDA process. Fixture provenance is in [protocol.md](protocol.md). `make check` also builds and invokes Hello World, Wormhole and Battery Status through the existing command host. This checks existing SDK/registration behavior without installing or replacing the active reader. Review the generated diff -before any later submission. Live desktop testing becomes meaningful only after -reader integration; the current source library provides no command to launch. +before any later submission. The source command can exercise connection and +consent UI; live desktop service testing still requires the pending reader +output/input owners. The first repository check exposed a pre-existing dependency metadata gap: the adjacent SDK imports reader configuration, which depends on go-toml v2.4.3. diff --git a/remote/src/connection_ui_test.go b/remote/src/connection_ui_test.go index e795a0d..50956b3 100644 --- a/remote/src/connection_ui_test.go +++ b/remote/src/connection_ui_test.go @@ -359,3 +359,22 @@ func TestConnectionWorkflowOldStatusCannotDisconnectNewEpoch(t *testing.T) { t.Fatal("old status controls disconnected a new connection", status) } } + +func TestConnectionWorkflowPendingApprovalExpiry(t *testing.T) { + c, f := fixtureCoordinator(t, nil) + action := approve(t, c, f, 1, "controller") + w := workflowFixture(t, c, action, endpoint{host: "relay.invalid", port: 6837}, nil) + f.events <- sdk.SessionEvent{Sequence: 2, Kind: "remote.revoked", Action: action.Action, Epoch: action.Epoch, Reason: "expired"} + awaitDone(t, w.done) + if !w.form().Done { + t.Fatal("expired approval retained connection controls") + } + if err := c.connect(action, w.target, "synthetic-key"); err != errLease { + t.Fatal("expired approval connected", err) + } + select { + case call := <-f.calls: + t.Fatal("expired setup made a reader call", call.method) + default: + } +} diff --git a/remote/src/session.go b/remote/src/session.go index 2d5e693..7862cd1 100644 --- a/remote/src/session.go +++ b/remote/src/session.go @@ -40,7 +40,7 @@ func (s *session) accept(epoch uint64, m message) (bool, error) { switch m.kind { case "channel_joined": v, ok := m.payload.(membership) - if !ok || s.state != "joining" || len(v.peers) > 1 { + if !ok || m.origin != 0 || s.state != "joining" || len(v.peers) > 1 { return s.suspend(errPeer) } s.state = "waiting" diff --git a/remote/src/session_test.go b/remote/src/session_test.go index bbd3c38..7a9f3ea 100644 --- a/remote/src/session_test.go +++ b/remote/src/session_test.go @@ -117,3 +117,11 @@ func TestSessionIgnoresUnsupportedEffects(t *testing.T) { t.Fatal("closed session accepted output") } } + +func TestSessionRejectsPeerOriginatedChannelJoin(t *testing.T) { + s, _ := newSession(controller, 1) + m := mustMessage(t, `{"type":"channel_joined","origin":7,"channel":"fixture","clients":[{"id":7,"connection_type":"slave"}]}`) + if accepted, err := s.accept(1, m); accepted || err != errPeer || s.state != "suspended" { + t.Fatal("peer supplied relay membership", accepted, err, s.state) + } +} diff --git a/remote/src/transport.go b/remote/src/transport.go index ab58075..605577e 100644 --- a/remote/src/transport.go +++ b/remote/src/transport.go @@ -188,6 +188,9 @@ func connect(ctx context.Context, e endpoint, r role, key string) (*relayConn, m } continue case "channel_joined": + if m.origin != 0 { + return nil, message{}, errPeer + } v := m.payload.(membership) if v.channel != key { return nil, message{}, errProtocol diff --git a/remote/src/transport_test.go b/remote/src/transport_test.go index 4ece359..20473a2 100644 --- a/remote/src/transport_test.go +++ b/remote/src/transport_test.go @@ -244,6 +244,7 @@ func TestJoinRejectsUnexpectedTraffic(t *testing.T) { cert, roots := testCertificate(t, true) for _, reply := range []string{ `{"type":"channel_joined","channel":"wrong-fixture"}`, + `{"type":"channel_joined","origin":7,"channel":"synthetic-fixture","clients":[{"id":7,"connection_type":"slave"}]}`, `{"type":"error","message":"do not expose this text"}`, `{"type":"speak","origin":7,"sequence":["before join"]}`, `{"type":"ping","origin":7}`,