fix(security): add content security policy#2353
Open
jeanduplessis wants to merge 7 commits intomainfrom
Open
Conversation
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (5 files)
Reviewed by gpt-5.4-20260305 · 593,802 tokens |
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.
Summary
Code-related pentest findings [private access to Kilo team members only] are now addressed without broad product rewrites. Each fix focuses on closing the reported behavior while preserving existing auth, analytics, payments, and device-token flows.
M3: Global Content Security Policy
Content-Security-Policyinproxy.ts. GTM/Impact bootstrap code is served from same-origin script routes instead of inline root-layout scripts, so the root layout does not callheaders()and does not force site-wide dynamic rendering just for CSP.script-srcwithunsafe-inlineso statically rendered pages continue hydrating.CSP_ADDITIONAL_SCRIPT_SRC,CSP_ADDITIONAL_CONNECT_SRC,CSP_ADDITIONAL_IMG_SRC,CSP_ADDITIONAL_STYLE_SRC,CSP_ADDITIONAL_FONT_SRC,CSP_ADDITIONAL_FRAME_SRC,CSP_ADDITIONAL_WORKER_SRC,CSP_ADDITIONAL_MEDIA_SRC) so production-only third-party sources can be added without code changes.script-src 'unsafe-inline'andstyle-src 'unsafe-inline'for Next.js static App Router compatibility and runtime styles. This is weaker than nonce-only CSP but safer than breaking hydration or forcing every route dynamic, and it can be tightened later with a hash/SRI rollout.report-uri/report-to, then enforced after reviewing real production violation reports.Split out from superseded monolithic PR #2347 so M3 can be reviewed, deployed, and rolled back independently.
Verification
.plans/pentest-findings.mdfor code-related L1 scope./api/userreturning401after revocation with stale cookie, re-login after revocation, and stale admin route rejection for/admin/api/credit-categories.Visual Changes
N/A
Reviewer Notes
Code Reviewer Notes
apps/web/src/lib/security-headers.tsand applied fromproxy.ts.headers()in the root layout.frame-srcincludes YouTube and*.d.kiloapps.io;connect-srcincludes*.d.kiloapps.iofor app-builder preview polling.dataLayerambient fix so this PR typechecks independently when targetingmain; this overlaps safely with the privacy split PR if either lands first.