Skip to content

fix: drop style-src 'unsafe-inline' from the CSP - #23

Merged
wonmors merged 2 commits into
mainfrom
fix/csp-no-inline-styles
Nov 14, 2026
Merged

wonmors merged 2 commits into
mainfrom
fix/csp-no-inline-styles

Conversation

@xnosir

@xnosir xnosir commented Nov 14, 2026

Copy link
Copy Markdown
Member

Overview

Issue Closes #7
Scope deploy/Caddyfile (CSP), tools/render-pages.mjs + generated pages, site/assets/css/site.css, tools/check-site.mjs, docs
Deploy the new CSP ships with the site container on merge

Problem

The CSP allowed style-src 'unsafe-inline' because the footer used two style attributes (residual risk in docs/ASSURANCE.md).

Change

  • Footer styles moved to .foot .disc--by / .disc--note in site.css; pages regenerated.
  • CSP: style-src 'self' 'sha256-RYwk...'. The hash is the favicon <style> (dark-mode colours); without it the favicon loses its stroke under the new CSP.
  • check-site.mjs fails on a style attribute or <style> in a page, and on an SVG <style> whose hash is not in the CSP.

Proof

Check Result
npm test (unit + 22 e2e under the Caddyfile CSP) pass
npm run lint 0 warnings
Local Chromium under new CSP footer margins 14px / 10px, favicon stroke rgb(30,104,80), 0 console errors
check-site negative test (favicon edited) fails with the new hash to add

The two inline footer styles move into site.css as .disc--by and .disc--note. The favicon keeps its <style> (it carries the dark-mode colours), allowed by its sha256 hash. tools/check-site.mjs now fails on a style attribute or <style> in a page, and on an SVG <style> whose hash is missing from the CSP.

Closes #7

Signed-off-by: xnosir <283333996+xnosir@users.noreply.github.com>
@xnosir
xnosir requested a review from a team as a code owner November 14, 2026 15:28
Signed-off-by: xnosir <283333996+xnosir@users.noreply.github.com>
@wonmors
wonmors merged commit 4c8356c into main Nov 14, 2026
5 checks passed
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.

1 participant