fix(security): drop 'unsafe-eval' from CSP script-src (follow-up to #112) #114
No reviewers
Labels
No labels
backend
bug
completed
documentation
duplicate
enhancement
feature
frontend
good first issue
help wanted
in-progress
invalid
performance
phase-1
Phase1
Phase2
Phase3
planning
question
refactor
security
test
testing
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Kalle/ATM!114
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/csp-unsafe-eval"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Plan
Den dokumentierten Follow-up aus PR #112 schließen:
'unsafe-eval'aus CSPscript-srcentfernen — es hielt die zweithäufigste XSS-Payload-Klasse (eval()/new Functionfür alles, was an der Nonce vorbei schmuggelt) offen. Deliverable: eval-freie Policy überall, dev-HMR bleibt funktional.Outcome
src/lib/csp.ts:buildCspHeader(nonce, { allowDevEval } = { allowDevEval: false })— Default false, Opt-in fügt'unsafe-eval'hinzusrc/middleware.ts: setztallowDevEvalausschließlich außerhalb von production (NODE_ENV-Gate; im Edge-Bundle statisch wegoptimiert — verifiziert im kompilierten Chunk:allowDevEval:!1als Default, kein Runtime-Env-Lookup)next.config.js: statisches Fallback (middleware-unerreichbare Pfade, z. B./_next/static/*) ebenfalls eval-freicsp-nonce.test.ts(eval-frei by default) + deterministischervi.stubEnv-Fall incsp-middleware.test.ts(„eval gate follows NODE_ENV deterministically")new Function, 0× String-arg-setTimeout,importScriptsnur im Worker-Chunk-Loading (worker-src 'self' blob:— nicht eval-gebannt)Impact on release goals
script-srcist jetzt nonce-only +'self'('unsafe-inline'→ #112,'unsafe-eval'→ dieser PR). Eval-class XSS zu.Blackbox
python3 scripts/blackbox_test.py --target testing→ red-first bewiesen: 113/114, exakt 25f rot (der Pre-Fix-Build läuft dort; grün erst nach Merge+Deploy)next build+next start): 25f GRÜN, Gesamt 101/102 — die eine Rot ist Test 16 (PDF smart-import, sandbox-bedingt: keinAI_BACKENDlokal; auf testing ✓)tscclean;next buildgrünSix-perspectives check
Risk
Gering. Policy-Builder ohne Verhaltensänderung am App-Code; Nonce-Stempfung live verifiziert. Residual: (a) Playwright-Interaktivitätstest in der Sandbox nicht möglich (Chromium-Download gedrosselt) — stattdessen äquivalenter Nonce-Stempel-Nachweis am Server-HTML; (b) Sandbox-Fallstrick dokumentiert: ein veralteter
next-serverauf dem Port machte die alte Policy sichtbar. Hinweis aus #112: kein CI-Grün auf PR-Heads möglich (account-weites GitHub-Actions-Billing-Problem, identische Annotation auf dev-HEAD) — lokale Äquivalent-Verifikation mit exakten CI-Befehlen statt dessen.Checklist
devtest:→fix(security):→docs(development):)Created by an AI agent (OpenHands) on behalf of the ATM automation.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.