Skip to content

Require pairing for WebRTC browser viewers - #794

Open
jmccaffrey-nv wants to merge 3 commits into
NVIDIA:mainfrom
jmccaffrey-nv:dev/jmccaffrey/webrtc-viewer-authorization
Open

jmccaffrey-nv wants to merge 3 commits into
NVIDIA:mainfrom
jmccaffrey-nv:dev/jmccaffrey/webrtc-viewer-authorization

Conversation

@jmccaffrey-nv

@jmccaffrey-nv jmccaffrey-nv commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

A V2 WebRTC server admitted a new or replacement viewer from any client that could reach its port. This PR requires the viewer to be paired with the server's owner credential, and it is still one click on a local launch.

  • Admission. Offers and file uploads need the owner credential and must pass a strict Host/Origin policy. Off loopback, the page must be served from an HTTPS origin. Authorization runs before the offer or upload body is parsed. Generation checks reject requests that were in flight when the viewer changed.
  • Default launch. The serving rank creates a private credential once at ~/.config/flashdreams/webrtc-token (mode 0600, in a 0700 folder) and reuses it across restarts. On an interactive terminal the runner prints a one-click link, http://127.0.0.1:PORT/#pair=…. The code travels in the URL fragment, which the browser never sends to the server, and the page removes it from the address bar. Logs and batch output show only the URL and the path to paste the code from.
  • Options.
    • FLASHDREAMS_WEBRTC_TOKEN_FILE selects a managed credential.
    • FLASHDREAMS_WEBRTC_ALLOWED_ORIGINS allows a TLS front end.
    • --no-login keeps tokenless loopback for a trusted single-user machine. It is refused off loopback, with configured origins, or with a token file, in every mode that serves a viewer, including HandDreams.
  • Windows. The credential reader uses O_NOFOLLOW, O_NONBLOCK and geteuid only where they exist. Owner and mode are checked on POSIX; on Windows the user profile's ACLs protect the file.
  • Viewer replacement. When a viewer is replaced, the input it was holding is released: keyboard, mouse, gamepad, wheel and native UI input. This goes through a focus-loss event that leaves model history and reset generations unchanged. Callbacks, frames, uploads and deferred input from the retired viewer are dropped. The retired track and transport are always closed, even when a viewer callback raises.
  • Docs. The CLI guide covers the default flow, the paste fallback, --no-login and credential rotation. Walkthroughs, the HandDreams launcher and the multi-node Slurm probe now open the viewer on loopback with an SSH forward instead of --host 0.0.0.0.

Validation

All checks ran on CPU.

  • pytest -m ci_cpu:
    • flashdreams/test_v2: 459 passed.
    • HandDreams app, controller input and launcher tests: 1,788 passed, 3 skipped. One failure, test_mode_is_registered_as_a_v2_client_window_plugin, needs the controller-input package installed so its entry point is registered. It fails the same way on main in this environment.
    • Renderer and app input tests (imgui, SlangPy, OmniDreams game engine, Crazy Robotaxi, Interactive Drive, action2v, cam2v): 318 passed.
  • ty check reports no new diagnostics.
  • The pre-commit hooks pass (whitespace, end of file, ruff, ruff format).
  • zensical build passes.

Not exercised: GPU rendering, a real browser or TLS proxy, a real Windows host, and the full repository ci_cpu run (CI covers it).

🤖 Generated with Claude Code

A V2 WebRTC server accepted a new or replacement viewer from any client
that could reach its port. Viewer admission and file uploads now require
an owner credential, a strict Host/Origin policy and an HTTPS origin
outside loopback. Authorization runs before offer parsing and upload
reads, and generation checks fence requests that were in flight when
the viewer changed.

By default the serving rank creates a private credential once
(~/.config/flashdreams/webrtc-token) and reuses it. On an interactive
terminal the runner prints a one-click link that carries the code in the
URL fragment, which is never sent to the server; logs get only the URL
and the credential path. --no-login keeps tokenless loopback for a
trusted single-user machine and is refused anywhere else. The credential
is also read on Windows, where profile ACLs protect it.

Replacing a viewer releases its held keyboard, mouse, gamepad, wheel and
native UI input through a focus-loss boundary that leaves model history
and reset generations unchanged. Retired callbacks, frames, uploads and
deferred input are dropped. Walkthroughs and the HandDreams launcher open
the viewer on loopback with an SSH forward instead of --host 0.0.0.0.

Signed-off-by: Jonathan McCaffrey <jmccaffrey@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jmccaffrey-nv
jmccaffrey-nv requested a review from a team as a code owner November 26, 2026 01:29
@copy-pr-bot

copy-pr-bot Bot commented Nov 26, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@jmccaffrey-nv

Copy link
Copy Markdown
Collaborator Author

/ok to test 41d2ad4

@greptile-apps

greptile-apps Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; no new actionable issues remain.RetriggerView in GreptileConfidence Score: 5/5

[Critical impact] The PR appears safe to merge; no new actionable issues remain.

Summary

The PR requires browser pairing for standard WebRTC launches and clears retired viewers' input without resetting model history.

  • WebRTC viewers now need the server owner's pairing code.
  • Replacing a browser viewer releases its held controls and queued input.
  • Remote launch guides now use pairing and loopback forwarding.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Browser request] --> B{Host and Origin allowed?}
  B -->|No| C[Reject request]
  B -->|Yes| D{Owner credential accepted?}
  D -->|No| C
  D -->|Yes| E[Negotiate viewer]
  E --> F{Credential still current?}
  F -->|No| C
  F -->|Yes| G[Retire old viewer and clear its input]
  G --> H[Install new viewer]
Loading

Reviews (3) · Last reviewed commit: "Launch the HandDreams CLI test on loopba..." · Reviewed by Greptile

HandDreams created the WebRTC viewer without running the WebRTC mode's
argument checks, so --no-login with FLASHDREAMS_WEBRTC_TOKEN_FILE set
loaded the credential instead of refusing the conflicting options.
Creating the WebRTC window now runs those checks, and the Isaac Teleop
and remote Quest modes apply them before anything is built.

The HandDreams launcher also printed the LAN address for the viewer,
which now listens on loopback. It prints the loopback URL and the SSH
forward to reach it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Jonathan McCaffrey <jmccaffrey@nvidia.com>

@gtong-nv gtong-nv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jmccaffrey-nv

Copy link
Copy Markdown
Collaborator Author

/ok to test 3bbae74

The HandDreams CLI test passed --host 0.0.0.0, which the WebRTC mode now
refuses without an approved origin, so both of its cases exited with
status 2 in CPU CI. The test only checks how the launcher parses its
arguments, so it now uses 127.0.0.1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Jonathan McCaffrey <jmccaffrey@nvidia.com>

This branch has not been deployed

No deployments
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.

2 participants