Skip to content

feat(security): implement Content Security Policy - #82

Merged
kellenmurphy merged 2 commits into
mainfrom
feat/csp
May 28, 2026
Merged

feat(security): implement Content Security Policy#82
kellenmurphy merged 2 commits into
mainfrom
feat/csp

Conversation

@kellenmurphy

Copy link
Copy Markdown
Owner

Summary

  • CSP via kit.cspmode: 'hash', delivered as an HTTP response header (not meta tag, so frame-ancestors is enforced by the Cloudflare Worker SSR path)
  • Directives: default-src 'self'; script-src 'self' <hashes> (no unsafe-inline); style-src 'self'; connect/img-src 'self'; font/object-src 'none'; base-uri/form-action 'self'; frame-ancestors 'none'; upgrade-insecure-requests
  • Inline script handling: theme-detection script in app.html manually hashed; SvelteKit auto-hashes its bootstrap script per render
  • style="display: contents"class="contents" (Tailwind utility) to eliminate the one inline style attribute that would have required unsafe-hashes
  • SECURITY.md: new Runtime protections section; CSP promoted from planned to shipped; method restriction (SvelteKit 405s non-GET automatically), CSP reporting gap, and coordinated disclosure policy documented

Test plan

  • CI passes (all 5 scanners green)
  • After merge: verify live site at samlguy.com — check response headers for content-security-policy, confirm SAML/JWT decode works, confirm no console CSP violations

- Add kit.csp to svelte.config.js with mode: 'hash':
  default-src/connect-src/img-src 'self'; script-src with hashes;
  style-src 'self'; font-src/object-src 'none'; base-uri/form-action
  'self'; frame-ancestors 'none'; upgrade-insecure-requests
- CSP delivered as HTTP header (Cloudflare Worker SSR) so frame-ancestors
  is enforced; X-Frame-Options remains as legacy fallback
- Replace style="display: contents" in app.html with Tailwind contents
  class to eliminate the one inline style attribute
- Manually hash the theme-detection inline script in app.html; SvelteKit
  auto-hashes its bootstrap script per render
- Document method restriction (405 on non-GET), CSP reporting gap,
  and coordinated disclosure policy in SECURITY.md
- Restructure SECURITY.md: new Runtime protections section between
  How the application works and Supply chain controls
@codecov

codecov Bot commented May 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@kellenmurphy
kellenmurphy merged commit ed26434 into main May 28, 2026
12 checks passed
@kellenmurphy
kellenmurphy deleted the feat/csp branch May 28, 2026 21:02
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