Skip to content

Only let ConnectHub's own page open the stream - #52

Merged
rangoDJ merged 1 commit into
mainfrom
fix/selkies-same-origin
Oct 7, 2026
Merged

rangoDJ merged 1 commit into
mainfrom
fix/selkies-same-origin

Conversation

@rangoDJ

@rangoDJ rangoDJ commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Fixes #51

What changed

  • Dockerfile: ENV SELKIES_ALLOWED_ORIGINS= after the base-env check, overriding the base image's * with Selkies' same-origin default. The mirrored base ENV block keeps * so check_base_env.sh still verifies it against the base.
  • README: new "Which pages may open the stream" section (how to allow another origin; avoid *).
  • docker-compose.yml: commented SELKIES_ALLOWED_ORIGINS example.

Why it keeps working behind proxies

Selkies' _is_origin_allowed() accepts a request whose Origin hostname equals the Host header when that header has no port. ConnectHub's nginx forwards Host $host (no port), so the browser's Origin matches regardless of the external port or scheme.

Testing

Ran Selkies' real _is_origin_allowed() (from the deployed stream_server.py) with allowed_origins empty against the requests ConnectHub's setups produce:

  • allowed: Cloudflare tunnel (https://hub.example / Host: hub.example), LAN http://IP:8080, LAN https://IP:8443, localhost:8080, non-browser clients without an Origin
  • rejected: a sibling subdomain, an unrelated site, a lookalike hub.example.evil.example
  • with *, the sibling subdomain was allowed (the gap being closed)

Not yet tested in a running container; to confirm after deploy, the stream should connect as before.

🤖 Generated with Claude Code

The base image sets SELKIES_ALLOWED_ORIGINS=*, disabling Selkies' check on
which pages may open the stream WebSocket. The SameSite=Lax session cookie
keeps out other sites, but SameSite is per site, so a page on a sibling
subdomain still got the cookie and could view and control the desktop.
Restore Selkies' same-origin default (empty). It compares the Origin's
hostname with the Host nginx forwards, so proxies, tunnels, LAN access and
localhost keep working; other origins can still be listed in compose.

Fixes #51

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rangoDJ
rangoDJ merged commit 383b33a into main Oct 7, 2026
4 checks passed
@rangoDJ
rangoDJ deleted the fix/selkies-same-origin branch October 7, 2026 22:55
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.

Restore Selkies' same-origin check on the stream WebSocket

1 participant