Skip to content

Bound writes: a relay client writes only its own participant, as itself - #807

Merged
transfix merged 1 commit into
feat/h1-admissionfrom
feat/h1-bound-writes
Oct 25, 2026
Merged

transfix merged 1 commit into
feat/h1-admissionfrom
feat/h1-bound-writes

Conversation

@transfix

Copy link
Copy Markdown
Owner

Stacked on #796 (feat/h1-admission). This is §5e item 1 of the conference roadmap, connection-bound identity, without a credential yet.

The problem

The relay applied and forwarded whatever a client sent. Any connected browser or native client could:

  • write another participant's intent and walk their avatar;
  • overwrite the server holon's poses, the scene or the area-of-interest settings;
  • send mutations or media under another participant's origin;
  • push a snapshot that the relay applied as a bulk load.

holon_sync.h called "sole writer" a convention.

What this does

  • state_inbound_gate (new, cvc/state) is installed with state_transport::set_inbound_gate on both relay transports. One gate is shared, so the binding spans gRPC and WebSocket. It governs only the connections the relay accepted. Connections it dialed, the WS<->gRPC bridge and the relay's own writes are not gated.

    • Identity: a connection speaks only as the node id (pid) of its first Hello. One live connection holds a pid at a time; the first claim wins until it closes.
      • A holder silent for 6 s (three missed link probes; a live client answers every Ping) is taken over by the next claim. A dropped network otherwise leaves the old stream open, and gRPC has no idle reaper.
      • The relay's own ids, its transport's and its shards', are never a client's. Such a client's frames would skip the relay's ingest yet still be fanned out, and could spend the relay's sequence numbers ahead of it, so every client would drop the relay's real writes as duplicates.
    • Origin: mutations, messages and media must name that pid, and a gRPC heartbeat must name it as its node.
    • Snapshots: a client's SnapshotResponse is never applied. A snapshot request is answered only for a connection that speaks as itself.
    • Departure: a close counts as that peer leaving only if the connection still held its pid. A duplicate claimant's close, or a displaced holder's, does not retract the participant.
    • Refused frames are not applied, forwarded or bridged, and are counted in total_inbound_rejected(). Over WS, the next broadcast also re-sends the relay's value to the client.
  • room_write_gate (conference) is the room's rule:

    • a participant writes only inside conf.rooms.<room>.participants.<pid>, and only value, touch or data() ops;
    • never the relay's keys there: pose, net.relay, and streams.<kind>.ready (SFU);
    • only on canonical paths of at most 16 segments and 512 bytes. A canonical path has no empty or whitespace-padded segment, which the tree would trim onto another key, such as bob..pose;
    • only for a pid that is a single identifier.

    An inventory of every client write (arigl, the browser client, the conference verbs, the bench) found nothing outside this rule.

  • arisrv: --bind-writes on|off, on by default and not an S7 switch. It logs bound writes: refused N client frame(s) when the count grows. The bench mirrors the switch and records it in its JSON.

  • cvc.dll: the gate's holder map is file-local, so the gate adds 73 names to cvc.dll (65,200 of 65,535). It added 219 before that change.

Review

An independent review of the first version found these, all fixed here:

  • a client could claim the relay's own id;
  • .. and padded path segments got past the pose exclusion;
  • a single deep path made the per-tick roster walk quadratic;
  • a race between the departure check and the release;
  • unidentified gRPC snapshot requests were answered;
  • streams.<kind>.ready belongs to the relay.

It also found that the first adversarial test couldn't catch a broken pose rule, because the server rewrites poses every tick. The test now checks what the relay applied from each client.

Testing

  • New tests:
    • On both gRPC and WS: InboundGate{TakesOnlyWhatAPeerMayWriteAsItself, BindsANodeIdToOne*, RefusesTheRelaysOwnId, HandsASilentHoldersIdOver}. They cover another peer's path, spoofed origin on a mutation, message and media frame, a pushed snapshot, a duplicate claim, the departure rule, takeover through a real connection, and the relay's id.
    • InboundGateSpansBothTransports.
    • RoomWriteGate.{AParticipantWritesOnlyItsOwnSubtree, BindsOneConnectionPerNodeId, ASilentHolderIsTakenOver}.
    • RoomRelayLoopbackTest.ClientWritesOnlyItsOwnParticipant: client M writes A's intent and pose, its own pose by normalising paths, the scene and the AOI, and sends A's intent as A. Nothing the relay applied from M lies outside M's participant or touches a pose, A never moves and never receives an intent, and M's own walk still works.
    • With the relay-id or canonical-path check removed, these tests fail.
  • Changed tests: the loopback test relay binds writes like arisrv.
    • NoIntentOrUiDocsLeak now expects D's ui.docs echo to be refused by the write gate.
    • ControlPlaneEgressDrops turns bound writes off for its "before S7" baseline. That relay had none, and bound writes would refuse the echo it measures.
  • Windows, static WS tree: WS 32/32, gRPC 42/42, room relay 12/12, room intrinsics 7/7.
  • Windows, shared build: full suite 4,858/4,858, with *Convergence* excluded as in CI.
  • Formatting: clang-format 18.1.8 (CI's version) reports no changes.

Known limits

These are also listed in the roadmap doc, §5h.1 ("Bound writes").

  • No authentication: a client can claim any pid no one holds, a departed participant's included. Room tokens are §5f.
  • Reconnect wait: a reconnect whose old, silently dead stream still holds the pid is refused for up to 6 s.
  • Stale local copies: a refused gRPC client keeps its rejected value locally until the relay next writes that path.
  • Impostors still get a view: a connection refused a held pid still receives that pid's filtered view, because delivery isn't access control yet (§5e item 2).
  • No size or rate limits inside a client's own participant (Phase 7).
  • Ungated chunk responses: they aren't checked against their request, and no relay installs a hydrator yet.
  • Ungated media plane: the separate gRPC media plane (stream_relay, routed by stream id) isn't gated.

The relay applied and forwarded whatever a client sent: another
participant's intent, the server holon's poses, the scene, mutations or
media naming another origin, even a snapshot pushed at it.

state_inbound_gate (cvc/state), installed with
state_transport::set_inbound_gate on gRPC and WS, governs what a
transport takes from the connections it accepts. Dialed connections,
the bridge and the relay's own writes are not gated.

- Identity: a connection speaks only as the node id of its first Hello.
  One live connection holds a node id at a time. The first claim wins
  until it closes, or until it has been silent for 6 s (three missed
  link probes), when the next claim takes it over: a dropped network
  leaves the old stream open. The relay's own ids (its transport's and
  its shards') are never a client's.
- Origin: mutations, messages and media must name that id, and gRPC
  heartbeats must name it as their node. A client's SnapshotResponse is
  never applied, and a snapshot request is answered only for a
  connection speaking as itself.
- Departure: a close is that peer leaving only when the connection
  still held its id.
- Refused frames are not applied, forwarded or bridged; they are counted
  in total_inbound_rejected().

room_write_gate is the room's rule:
- a participant writes only inside conf.rooms.<room>.participants.<pid>,
  with value, touch or data ops;
- never the relay's keys there: pose, net.relay, and streams.<kind>.ready;
- only on canonical paths of at most 16 segments and 512 bytes (no empty
  or padded segment, which the tree would trim onto another key);
- and only for a pid that is one identifier.

Every client write today fits this rule.

arisrv --bind-writes on|off (default on; not an S7 switch) installs one
gate on both transports, and logs refusals as their count grows. The
bench mirrors it. The gate's holder map is file-local, so cvc.dll grows
only 71 names (65,198 of 65,535).

Tests:
- InboundGate{TakesOnlyWhatAPeerMayWriteAsItself, BindsANodeIdTo*,
  RefusesTheRelaysOwnId, HandsASilentHoldersIdOver} for gRPC and WS, and
  InboundGateSpansBothTransports;
- RoomWriteGate.* (the rule, binding, takeover);
- RoomRelayLoopbackTest.ClientWritesOnlyItsOwnParticipant: what the
  relay applies from a client that writes A's intent and pose, its own
  pose by normalising paths, the scene and the AOI, and A's intent as A.
  Mutants without the relay-id or canonical-path checks fail these.
- NoIntentOrUiDocsLeak now expects the echo refused by the write gate,
  and ControlPlaneEgressDrops's pre-S7 baseline turns bound writes off.
@transfix
transfix merged commit 2554995 into feat/h1-admission Oct 25, 2026
6 checks passed
transfix added a commit that referenced this pull request Oct 25, 2026
Bound writes (#807) is now squashed into feat/h1-admission; merged with its head as the base, so only this branch's own changes apply. The tree is unchanged.
transfix added a commit that referenced this pull request Oct 26, 2026
… field fixes, per-viewer video rungs and Opus mics (#796)

The conference stack after #783, squashed through feat/h1-admission:

- #796 admission hold: a late joiner's admit snapshot goes through its AOI
  filter (no other participant's intent, the outer peer by push).
- #807 bound writes: a relay client writes only its own participant subtree,
  as itself.
- #809 room token and a default device identity (section 5f); #816 device keys,
  TOFU-pinned by the relay.
- #819 field fixes: a volume slider that holds still, a mover's own avatar
  that no longer jumps (the WS re-broadcast echoed its intent; the clock slews
  instead of seeking), and about 1/8 of the video bandwidth.
- #821 per-viewer video rungs (the relay re-encodes each camera for each
  viewer's link: full / half / quarter / thumb / off, adapted from queueing,
  drops and budget), Opus mics (32 kbit/s instead of 1.5 Mbit/s), a camera-off
  flag, status dots, and libopus for the libcvc recipe (cvcpkg libopus cvc.8).
- 05d0d60: the clock slews after any first sample, not only after a first
  seek (HolonTest.AClientInStepFromItsFirstSampleStillSlews), and two relay
  loopback tests bound wall-clock rates loosely enough for a Debug gRPC runner.
@transfix
transfix deleted the feat/h1-bound-writes branch October 29, 2026 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant