From 87725dc7a2da27c2ca3b9e58af751f0e6f8c9de7 Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Wed, 30 Sep 2026 13:09:47 +0200 Subject: fix: the page connects to its own origin and reCAPTCHA, nowhere else connect-src drops https: and wss: in both policies. Checked against Google's reCAPTCHA test keys: in Chrome widget, token and registration unchanged; in Firefox the widget loads; no violation reported in either. Co-Authored-By: Claude Opus 5.5 --- packages/meshbay-hub/tests/test_desktop_shell.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'packages/meshbay-hub/tests/test_desktop_shell.py') diff --git a/packages/meshbay-hub/tests/test_desktop_shell.py b/packages/meshbay-hub/tests/test_desktop_shell.py index 732ba07..6e1c634 100644 --- a/packages/meshbay-hub/tests/test_desktop_shell.py +++ b/packages/meshbay-hub/tests/test_desktop_shell.py @@ -226,14 +226,17 @@ def _directive(name: str) -> str: def test_the_hub_is_reachable_but_never_executable(): """ - connect-src allows the hub's API and its signaling socket. script-src does - not: nothing the hub returns is ever executed. The only script sources are - 'self', the wasm eval token, and the two reCAPTCHA hosts (see the next - test) — never a bare `https:` scheme, which would let the hub's own origin - serve script. - """ - connect = _directive("connect-src") - assert "https:" in connect and "wss:" in connect + The page connects to its own files and to reCAPTCHA, nothing else: every + hub call leaves from the main process (a page on `app://` is refused by + CORS anyway), and the node arrives over WebRTC, which connect-src does not + govern. A bare `https:` there let injected script post anything anywhere. + script-src never names the hub: nothing it returns is ever executed. The + only script sources are 'self', the wasm eval token, and the two reCAPTCHA + hosts (see the next test) — never a bare `https:` scheme, which would let + the hub's own origin serve script. + """ + connect = _directive("connect-src").split()[1:] + assert set(connect) == {"'self'", "https://www.google.com", "https://www.gstatic.com"} script = _directive("script-src") assert script, "no script-src directive" -- cgit v1.2.3