Repository navigation
Conversation
…ipt nonce Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.
Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 49 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…upes before logging Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #1311 (report-only step; enforcing is a later change after the report window)
What
src/lib/csp.ts: the policy.script-src 'self' 'nonce-<per request>' 'strict-dynamic'(plus'unsafe-eval'in development only),default-src 'self', styles'self' 'unsafe-inline', imageshttps:(shop CDNs, asimages.remotePatterns),connect-srcadds the Supabase project,object-src 'none', the existingframe-ancestors,base-uri,form-action, andreport-uri /api/csp-report.src/proxy.ts: a fresh 128-bit nonce per page request, sent asContent-Security-Policy-Report-Onlyon the response and on the forwarded request, where Next.js 16 reads it (it accepts the report-only header) and puts the nonce on its own scripts. The enforcednext.config.mjsCSP (frame-ancestorsand friends) is unchanged.POST /api/csp-report: logs a violation (directive, blocked URL, page, source; origin and path only, no query string) and always answers 204. The body is read as a stream and dropped past 8 KB (with or withoutContent-Length); a report needs a directive and a page on this site's origin; each distinct violation is logged once per 10 minutes per instance, at most 200 distinct ones, so the public endpoint cannot flood the logs.Compatibility
<script type="application/ld+json">) is a data block, not a script:script-srcdoes not apply, so no nonce is needed./_vercel/*script added later and injected by the nonced runtime is allowed by'strict-dynamic'.script-src-elemreports. Enforcing therefore needs a decision once the reports are in: render those pages per request (nonce) or switch the policy to hashes. Report-only changes nothing for visitors meanwhile.Tests
src/lib/__tests__/csp.test.ts(added topnpm --filter web test): the directives, a fresh base64 nonce per request, the same policy on the response and on the forwarded request (x-middleware-request-*), no enforced CSP header, and the report endpoint logging without query strings, answering 204 to garbage, logging a repeated violation once, ignoring a report without a directive or for another site, and stopping an oversized streamed body within 16 KB.Review gate
Codex round 1: the 8 KB cap did not hold for a streamed body without
Content-Length, and any{"csp-report":{}}post was logged (log flooding): both fixed with tests. It also confirmed the ISR point above (cached HTML keeps the nonce it was rendered with, or none), which stays the open decision before enforcing.Checks
pnpm --filter web test,tsc --noEmit, eslint, prettier: green locally.🤖 Generated with Claude Code