From ceb997f6c1fa563a56fefe77cb5b77c9c8864159 Mon Sep 17 00:00:00 2001 From: rangoDJ <18576423+rangoDJ@users.noreply.github.com> Date: Wed, 7 Oct 2026 18:48:21 -0400 Subject: [PATCH] Only let ConnectHub's own page open the stream 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 --- Dockerfile | 6 ++++++ README.md | 10 ++++++++++ docker-compose.yml | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/Dockerfile b/Dockerfile index 5330891..711a8f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,6 +54,12 @@ COPY scripts/check_base_env.sh /tmp/check_base_env.sh RUN sh /tmp/check_base_env.sh /connecthub-base.env \ && rm -f /tmp/check_base_env.sh /connecthub-base.env +# The base's "*" lets any page open the stream WebSocket. The session cookie only keeps +# out other *sites*, so a page on a sibling subdomain (other.example.com beside +# hub.example.com) could still connect and control the desktop. Empty is Selkies' +# same-origin default: the Origin's hostname must match the Host nginx forwards. +ENV SELKIES_ALLOWED_ORIGINS= + # Install FreeRDP 3, GPU drivers for VA-API, Python 3, and utilities RUN apt-get update && apt-get install -y --no-install-recommends \ freerdp3-x11 \ diff --git a/README.md b/README.md index 485d905..a20eb70 100644 --- a/README.md +++ b/README.md @@ -203,6 +203,16 @@ The application will automatically recognize the authenticated user and grant ac `FORWARD_AUTH_TRUSTED_PROXIES` is **required**: the header is only honoured when the request comes from one of these IPs/CIDRs (your proxy's address or Docker network). Otherwise anyone reaching the container port directly could forge the header. Also avoid publishing the container port publicly in this mode. +### Which pages may open the stream + +Only ConnectHub's own page can open the remote desktop stream: Selkies checks that the browser's `Origin` matches the address you reached ConnectHub on, which keeps out pages on other sites, including other apps on sibling subdomains of the same domain. This works unchanged through a reverse proxy or tunnel, by LAN IP and on localhost. To allow another page (for example a portal that embeds ConnectHub from a different hostname), list its origin: + +```yaml +SELKIES_ALLOWED_ORIGINS=https://portal.example.com +``` + +Avoid `*`, which lets any page connect if the browser sends your session cookie. + --- ## Connection Types (RDP, VNC, SSH) diff --git a/docker-compose.yml b/docker-compose.yml index 6edc6a6..8354a84 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -60,6 +60,10 @@ services: # Session cookie Secure flag: auto (follows https), true, false - COOKIE_SECURE=${COOKIE_SECURE:-auto} + # Only ConnectHub's own page may open the stream. Add origins (comma-separated) only + # if another page must embed it, e.g. https://portal.example.com; avoid "*". + # - SELKIES_ALLOWED_ORIGINS= + # Optional custom session secret key (auto-generated if omitted) - SECRET_KEY=${SECRET_KEY:-}