From e7061a4e31d6ecc841a9ac110337f7540fb4dd3e Mon Sep 17 00:00:00 2001 From: waterWang <672684719@qq.com> Date: Sun, 23 Aug 2026 12:38:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(frontend):=20harden=20CSP=20=E2=80=94=20dro?= =?UTF-8?q?p=20style-src=20unsafe-inline,=20add=20connect-src=20and=20viol?= =?UTF-8?q?ation=20reporting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 #192 --- docs/deployment-strategy.md | 67 +++++++++++++++++++++++++ frontend/nginx.conf | 17 ++++++- frontend/src/components/ProgressBar.tsx | 16 +++++- frontend/src/pages/QueuesPage.tsx | 6 +-- frontend/src/styles/global.css | 9 ++++ 5 files changed, 107 insertions(+), 8 deletions(-) diff --git a/docs/deployment-strategy.md b/docs/deployment-strategy.md index b8172ef..40e4d1e 100644 --- a/docs/deployment-strategy.md +++ b/docs/deployment-strategy.md @@ -76,3 +76,70 @@ Production container deployments must adhere to the following security baselines - **Scope:** The final runtime image (not intermediate build stages), scanned directly from the local Docker daemon. - **Trade-off:** Setting the threshold to `critical` blocks deployment for any unpatched critical CVE in the final image. This is the strictest policy and may require occasional triage of false positives or accept-risk overrides. A more permissive "advisory-only" approach would log findings without blocking the pipeline; the current configuration chooses security gate over velocity. Teams may relax to `high` after evaluating their vulnerability management process. - **Artifacts:** Scan reports in SARIF format are uploaded as workflow artifacts for every run (including PRs). + +## Content Security Policy (CSP) Configuration + +The frontend production image (`frontend/nginx.conf`) ships a strict Content-Security-Policy: + +``` +default-src 'self'; +script-src 'self'; +style-src 'self' https://fonts.googleapis.com; +font-src 'self' https://fonts.gstatic.com; +img-src 'self' data:; +connect-src 'self' ${API_ORIGIN} https://soroban-testnet.stellar.org https://horizon-testnet.stellar.org; +frame-ancestors 'none'; +base-uri 'self'; +form-action 'self'; +report-uri /csp-report; +report-to csp-endpoint; +``` + +### Why no `'unsafe-inline'` in `style-src` + +The codebase renders all styles through Tailwind CSS class utilities plus a small +set of stylesheet classes (`global.css`). There are no inline `style="..."` attributes +or `