Skip to content

fix: production CSP allows connect-src to any localhost port #876

Closed

Description

@EVWorth

The CSP in src-tauri/tauri.conf.json:27 includes connect-src … http://localhost:* http://127.0.0.1:*. There is no devCsp, so this applies to release builds as well. Before this change, docs/SECURITY.md claimed the localhost sources were "removed in production builds"; #874 corrects the doc but not the policy.

Reproduce

grep -n connect-src src-tauri/tauri.conf.json
grep -rn "fetch(\|XMLHttpRequest\|WebSocket(" src --include=*.ts --include=*.tsx | grep -v __tests__

The first command shows the localhost sources. The second finds no frontend request to a loopback address, so the app does not appear to need them.

Cause

The localhost sources are probably left over from the Vite dev server (port 1420) and its HMR socket. Tauri already handles that case separately with devCsp or dev-only configuration.

Fix

Drop http://localhost:* http://127.0.0.1:* from csp and, if dev needs them, put them in app.security.devCsp. Then run just dev (HMR still works) and a release build (the app loads and IPC works), and update the CSP table in docs/SECURITY.md.

Activity

  1. added
    bug
    on Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions