You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Enhancement]: Enable CSP 3 support in app config #4488
Now that all the keywords and directives are supported for CSP 3, we should look into and attempt to enable $CSPEnabled in app/Config/App.
Background
This was identified as a follow-up task from PR #4485 (Update to CodeIgniter 4.7.2). The $CSPEnabled property was previously disabled due to CSP 3 tag incompatibilities, but those limitations have since been addressed in the updated configuration.
Tasks
Review the current CSP configuration in app/Config/ContentSecurityPolicy.php
Verify that all CSP 3 keywords and directives are properly supported
As part of the CodeIgniter 4.7.2 upgrade, four new CSP Level 3 properties were added to app/Config/ContentSecurityPolicy.php with the CI upstream defaults of 'self':
$scriptSrcElem = 'self'
$scriptSrcAttr = 'self'
$styleSrcElem = 'self'
$styleSrcAttr = 'self'
Issue
In CSP Level 3, the script-src-elem and script-src-attr directives supersedescript-src when present — the browser only falls back to script-src if the more-specific directive is absent. The same applies to style-src-elem / style-src-attr vs style-src.
This means the CI defaults of 'self' override — rather than refine — the existing $scriptSrc and $styleSrc rules, which allow:
If $CSPEnabled were set to true today without adjusting these properties, Google Maps scripts, Google Fonts stylesheets, and all inline scripts/styles would be blocked even though they are explicitly permitted in the broader $scriptSrc/$styleSrc rules.
Options to consider when enabling CSP
Option
Behaviour
Keep CI defaults ('self')
Stricter — CDN/inline permissions must be explicitly duplicated into each *-src-elem/attr property. Safer long-term for a tightened policy.
Set to null
Browser falls back to $scriptSrc/$styleSrc; existing allowlists remain effective immediately. Less migration work.
app/Config/App.php still has public bool $CSPEnabled = false; — CSP remains disabled by default. There is an open, unmerged PR addressing this directly: #4502 "feat: Enable Content Security Policy (CSP)" (linked to this issue), which has not landed on master yet. The enhancement requested here (enabling $CSPEnabled = true after verifying CSP 3 keyword/directive support) has not been completed.
Activity
coderabbitai commentedon Apr 13, 2026
CSP
*-src-elem/*-src-attrdirective defaultsCarried over from PR #4485 (discussion at #4485 (comment)).
Context
As part of the CodeIgniter 4.7.2 upgrade, four new CSP Level 3 properties were added to
app/Config/ContentSecurityPolicy.phpwith the CI upstream defaults of'self':$scriptSrcElem = 'self'$scriptSrcAttr = 'self'$styleSrcElem = 'self'$styleSrcAttr = 'self'Issue
In CSP Level 3, the
script-src-elemandscript-src-attrdirectives supersedescript-srcwhen present — the browser only falls back toscript-srcif the more-specific directive is absent. The same applies tostyle-src-elem/style-src-attrvsstyle-src.This means the CI defaults of
'self'override — rather than refine — the existing$scriptSrcand$styleSrcrules, which allow:unsafe-inline,unsafe-eval,www.google.com,www.gstatic.com(scripts)unsafe-inline, nonce placeholder,https://fonts.googleapis.com(styles)If
$CSPEnabledwere set totruetoday without adjusting these properties, Google Maps scripts, Google Fonts stylesheets, and all inline scripts/styles would be blocked even though they are explicitly permitted in the broader$scriptSrc/$styleSrcrules.Options to consider when enabling CSP
'self')*-src-elem/attrproperty. Safer long-term for a tightened policy.null$scriptSrc/$styleSrc; existing allowlists remain effective immediately. Less migration work.$scriptSrc/$styleSrcvaluesSince
$CSPEnabledremainsfalsethere is no current impact, but this should be resolved before enabling CSP.feat: Enable Content Security Policy (CSP)
[-]Enable $CSPEnabled in app/Config/App (CSP 3 Support)[/-][+][Enhancement]: Enable CSP 3 support in app config[/+]objecttothis commentedon Oct 27, 2026
Claude Issue Checker Agent (cc @objecttothis)
Investigated against current
master.Status: Still present (not yet merged).
app/Config/App.phpstill haspublic bool $CSPEnabled = false;— CSP remains disabled by default. There is an open, unmerged PR addressing this directly: #4502 "feat: Enable Content Security Policy (CSP)" (linked to this issue), which has not landed onmasteryet. The enhancement requested here (enabling$CSPEnabled = trueafter verifying CSP 3 keyword/directive support) has not been completed.