FULL AI ANALYSIS

Firefox refuses WSS WebSocket upgrade due to strict Content-Security-Policy connect-src while Chrome succeeds

Generated Oct 27, 2026, 9:31:39 AM

Analysis summary

Firefox enforces CSP 'connect-src' for WebSocket upgrades and treats the upgrade request originating inside a Service Worker differently: if a SW intercepts or proxies the request, Firefox requires the effective request origin to be allowed in connect-src and also verifies host/ scheme. The likely causes are: connect-src header not including wss scheme or exact origin as required by Firefox when Service Worker mediates the request; Service Worker may be initiating fetch/upgrade from a different origin context or with credentials that change the effective origin; or the CSP is delivered differently to worker contexts (HTTP header vs meta) and not applied in the worker scope. Chrome is more permissive in some service-worker CSP cases, which explains the cross-browser difference.

Possible causes

CSP connect-src lacks the explicit wss://ws.example.com origin, and Firefox enforces scheme+host for upgrades from documents and workers

80%

Service Worker intercepts or opens the connection from an origin/worker scope not covered by the page's CSP, and CSP for workers differs

60%

Firefox bug or stricter CSP policy enforcement compared to Chrome for Service Worker-initiated upgrades

30%

Subtle TLS hostname mismatch causing Firefox to treat connection as insecure and block under CSP/mixed-content rules

15%

Suggested fixes

1

Diagnostic step 1

Add the explicit wss origin to the server CSP header, e.g. Content-Security-Policy: connect-src 'self' wss://ws.example.com wss:;

2

Diagnostic step 2

Ensure the CSP header is served to worker scope (Service Worker fetches inherit header if same origin); if worker sits on another scope, set header for that scope too.

3

Diagnostic step 3

If Service Worker initiates the WS (via fetch or clients.openWindow), verify the worker's scope and that it runs under the same origin; instrument with console warnings in the worker.

4

Diagnostic step 4

Test by unregistering the service worker and confirming connect works; then re-register with updated CSP header and verify Firefox accepts the WSS upgrade.

5

Diagnostic step 5

If problem persists, capture network logs (about:networking) and browser console CSP reports and compare the exact effective-policy reported by Firefox to confirm mismatch.