Skip to content

fix(frontend): harden CSP — drop style-src unsafe-inline, add connect-src and violation reporting (Closes #192) - #219

Open
waterWang wants to merge 1 commit into
Stellar-Deejah:mainfrom
waterWang:fix/csp-security-hardening-192
Open

fix(frontend): harden CSP — drop style-src unsafe-inline, add connect-src and violation reporting (Closes #192)#219
waterWang wants to merge 1 commit into
Stellar-Deejah:mainfrom
waterWang:fix/csp-security-hardening-192

Conversation

@waterWang

Copy link
Copy Markdown

Summary

Hardens the frontend Content-Security-Policy in frontend/nginx.conf per issue #192:

  1. Removed 'unsafe-inline' from style-src — Tailwind emits class-based styles, and the two inline style usages in the codebase have been removed:
    • ProgressBar now sets its fill width via the CSSOM (element.style.width) inside a useEffect, which is not affected by CSP style-src.
    • QueuesPage card layout hints (content-visibility, contain-intrinsic-size) moved into a .queue-card stylesheet class in global.css.
  2. Added connect-src — allows the backend API origin (nginx $api_origin variable, defaults to http://localhost:4000) plus the Stellar Horizon and Soroban RPC endpoints the frontend speaks to at runtime.
  3. Strengthened additional directivesframe-ancestors 'none', base-uri 'self', form-action 'self', plus report-uri / Reporting-Endpoints for server-side violation reporting.

Inline scripts audit

Ran a production Vite build and inspected the output — the built dist/index.html contains no inline scripts:

<script type="module" crossorigin src="/assets/index-D-ilpdcd.js"></script>
<link rel="modulepreload" crossorigin href="/assets/vendor-Bt_XXEZL.js">

All scripts/styles/fonts load from src-allowed external sources, so script-src 'self' needs no sha256-* hash allowlist. Google Fonts are explicitly allowed via style-src https://fonts.googleapis.com and font-src https://fonts.gstatic.com.

Verification

  • vite build — 1652 modules, built successfully in 2.75s
  • tsc --noEmit — clean
  • vitest run — 10 test files / 40 tests all pass

Docs

docs/deployment-strategy.md gained a CSP section documenting the policy, the API-origin override, violation reporting, and a Report-Only → enforcement rollout guide.

Browser check (for maintainers)

When deployed, the Network tab should show the new CSP header (add_header Content-Security-Policy "…style-src 'self' https://fonts.googleapis.com;…"), and the browser console should be free of CSP violations for the production build.

Closes #192

…-src and violation reporting

- Remove 'unsafe-inline' from style-src in frontend/nginx.conf; the codebase
  now renders without inline style attributes (ProgressBar uses the CSSOM,
  QueuesPage card layout moved to the .queue-card stylesheet class)
- Add connect-src with the backend API origin () plus Stellar
  Horizon/Soroban RPC endpoints used at runtime
- Add frame-ancestors, base-uri, form-action directives and CSP violation
  reporting (report-uri / Reporting-Endpoints)
- Verified the Vite production build emits no inline scripts, so script-src
  'self' requires no sha256 hash allowlist
- Document the CSP policy, API-origin override and rollout guidance in
  docs/deployment-strategy.md

Closes Stellar-Deejah#192
@vercel

vercel Bot commented Aug 23, 2026

Copy link
Copy Markdown

@waterWang is attempting to deploy a commit to the Deejah Team on Vercel.

A member of the Team first needs to authorize it.

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.

Frontend: nginx.conf CSP allows unsafe-inline styles — weakens XSS protection unnecessarily

1 participant