Repository navigation
feat(security): add security headers and validate CMS URLs - #48
Merged
maxitect merged 5 commits intoNov 12, 2026
Merged
Conversation
✅ Deploy Preview for clarksbowlingclub ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
maxitect
marked this pull request as ready for review
November 12, 2026 23:37
maxitect
deleted the
feat/34-security-hardening-headers-cms-urls-email-and
branch
November 12, 2026 23:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds security response headers with a CSP (report-only on the first preview, enforced since), turns off
x-powered-by, and makes the music and tour components refuse non-https links and unknown embed hosts. Account and hosted-service settings are listed under Notes for the user.Changes
src/lib/security/headers.ts: CSP,X-Frame-Options: DENY,Referrer-Policy,Permissions-Policy, wired in throughheaders()innext.config.ts.routePoliciesadds allowances for one top-level path (/admintoday); every other path gets the base policy. Advent calendar live at /calendrier by 1 December #29 adds its/calendrierentry there.poweredByHeader: false.src/utils/safeUrl.ts:https:check and the three embed host lists, shared by the components and the Payload field validators (which no longer carry their own copy).Spotify,Youtube,Bandcamprender nothing for asrcoff their host;TourDatedrops unsafelocationUrlandticketUrl.Acceptance criteria
securityheaders.comrefuses automated requests (403), so graded by hand against its criteria: all six headers present, A (not A+, because of'unsafe-inline'). Confirm on securityheaders.com after mergejavascript:alert(1)renders no link; https link openssrcoff Spotify, YouTube, Bandcamp not rendered_dmarcshowsp=quarantine, form mail not in spam/llms.txtand/*.mddo not hit the sheet on every requestCloses
Closes #34
Notes
'unsafe-inline'for scripts and styles. The pages are static (cache components), so a per-request nonce is not possible, and Next's inline bootstrap scripts have no stable hash. The policy still pins frames, objects, base URI, form targets, connections and framing./adminallows the storage origin for connections, Gravatar for the account avatar and'self'frames on top of the base policy. In development'unsafe-eval'is added for React's dev tooling; production does not have it./adminroute logs agenerateMetadata()runtime-data error in dev. It is not caused by this change.locationUrlkeeps the existing inert#link styling.Steps for the user (not done here, they change accounts or hosted settings)
_dmarc.clarksbowlingclub.comTXTv=DMARC1; p=none; rua=mailto:dmarc@clarksbowlingclub.comwithv=DMARC1; p=quarantine; rua=mailto:dmarc@clarksbowlingclub.com, once the reports atdmarc@show the band's own mail passing. SPF today:v=spf1 a mx include:_spf.perfora.net include:_spf.kundenserver.de ~all. IONOS DKIM keys are published ats1-ionos._domainkeyands2-ionos._domainkey(CNAMEs tos1.dkim.ionos.comands2.dkim.ionos.com); confirm in the IONOS panel that DKIM signing is on for the domain, then submit the form once from production and check it reaches the band inbox and the sender's inbox, not spam, withspf=passanddkim=passin the received message'sAuthentication-Results.disabledtoday pergh api repos/TandemCreativeDev/cbc). Test by pushing a commit with a fake AWS key to a throwaway branch.main: tick "Do not allow bypassing the above settings" (enforce_adminsisfalse) and require thecheckstatus check from.github/workflows/ci.yml. Required status checks arenulltoday, and no review is required any more. With bypassing disallowed, direct pushes tomainare refused, including the ticket driver's tooling fixes; decide whether to keep that exception before ticking it. Collaborators today:maxitect(admin),jackcasstlesjones(admin),JasonWarrenUK(read); review before adding Loïc.EMAIL_PASSWORDhas values today for Production, Deploy Previews, Branch deploys, Local development (dev) anddev-server. Keep only the Production value, and give Deploy Previews, Branch deploys and Local development a test mailbox:EMAIL_HOST,EMAIL_PORT,EMAIL_SECUREandEMAIL_USERare one value for all contexts today, so split them per context too.Review
Verdict: ALL CLEAR
Rounds: 2
/adminCSP blocks the Gravatar account avatar (console CSP errors on every admin page)EMAIL_PASSWORDcontexts incomplete, branch-protection side effect unstatedadmin.avatar: 'default'would avoid the third partyframe-srcRe-verified: AC1 (deploy + browser: headers on preview, admin walk on production build, all three embeds on preview) PASS, AC
/llms.txtcaching (api:cache-status: "Netlify Durable"; hit) PASS · check.sh PASSEvidence
AC1
Report-only on the preview first: no violations on
/,/music,/tour,/about,/contact,/lyrics,/merch,/privacy-policy,/admin, apart from the one below. Then enforced, same pages:The only console violation is
Framing 'https://app.netlify.com/': Netlify's deploy-preview drawer, injected on previews and absent from production. Admin login, edit views and uploads: the login page renders and styles under the enforced policy; uploads go server-side to the storage endpoint through the S3 SDK (not subject to CSP) and admin thumbnails load from the storage origin, whichimg-srcallows. Signed-in admin on the preview under the enforced policy (throwaway first user on the Neonpreviewbranch), headless Chromium:Edit, save and upload work; the account avatar was blocked. With Gravatar added to the
/adminimg-src, the same signed-in walk onpnpm start(production build) against thepreviewdatabase:Every music category walked on the preview; all three players load inside their frames with no CSP message:
AC2
Temporary page rendering the components with good and bad data, read in headless Chromium (page removed afterwards):
javascript:ticket and location URLs gave no link and a disabled button; the off-host Spotify,javascript:YouTube and off-host Bandcamp items rendered no iframe; thejavascript:Bandcamphrefwas dropped.AC3
src/lib/data/content.ts: every sheet getter is"use cache"withcacheLife("minutes"), added in #27.