Skip to content

fix(csp): respect app 'unsafe-inline' — no nonce override (ADR-0100, #330) - #253

Merged
tina4stack merged 1 commit into
v3from
fix/csp-nonce-unsafe-inline-330
Oct 23, 2026
Merged

tina4stack merged 1 commit into
v3from
fix/csp-nonce-unsafe-inline-330

Conversation

@tina4stack

Copy link
Copy Markdown
Owner

Fixes tina4-php#330 (a regression since 3.13.143), at four-framework parity.

ADR-0088 injects a per-response nonce into script-src/style-src so the
framework's own inline content runs under the strict default CSP. The injector
added the nonce to whatever policy it was handed — including an app's own
TINA4_CSP. Under CSP Level 2+ a browser ignores 'unsafe-inline' in any
directive that also lists a nonce, so an app that deliberately allowed inline
through 'unsafe-inline' had all of it silently blocked after upgrading, with no
way to turn the injection off. Invisible to curl; only a real browser enforces it.

The rule now (ADR-0100): a script-src/style-src directive that already carries
'unsafe-inline' — present in the policy, or derived from an 'unsafe-inline'
default-src — gets no nonce. The app's explicit choice wins; its inline runs
and the framework's own inline rides the same allowance. The strict default policy
is unchanged and still nonced, an explicit directive without 'unsafe-inline' is
still nonced, and a policy that opts into inline on one axis only is nonced on the
other.

Verified at HEAD, no mocks (the real injector, a pure string transform): 6/6 in
all four frameworks, each mutation-proven — dropping the guard turns 4 cases red.
New contract invariant csp-nonce-respects-unsafe-inline in
securityheaders_contract.json.

🤖 Generated with Claude Code

… (ADR-0100, #330)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Signed-off-by: Andre van Zuydam <andrevanzuydam@gmail.com>
@tina4stack
tina4stack force-pushed the fix/csp-nonce-unsafe-inline-330 branch from d37b288 to 9f02d48 Compare October 23, 2026 14:26
@tina4stack
tina4stack merged commit 52db6d7 into v3 Oct 23, 2026
14 checks passed
@tina4stack
tina4stack deleted the fix/csp-nonce-unsafe-inline-330 branch October 23, 2026 14:51
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.

2 participants