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
Yes, the bug happens even if the security option is not customized
Security options
security: {nonce: true,corsHandler: false,headers: {xXSSProtection: '1',crossOriginEmbedderPolicy: false,contentSecurityPolicy: {'default-src': ["'self'"],'style-src': ["'self'",// fallback value for older browsers, automatically removed if `strict-dynamic` is supported.//"'nonce-{{nonce}}'","'unsafe-inline'",'fonts.googleapis.com','cdnjs.cloudflare.com','cdn.jsdelivr.net',],'script-src': ["'self'",// fallback value for older browsers, automatically removed if `strict-dynamic` is supported."'nonce-{{nonce}}'","'strict-dynamic'",'https:','cdnjs.cloudflare.com','cdn.jsdelivr.net','cdn.sheetjs.com',],'script-src-attr': ["'self'",// fallback value for older browsers, automatically removed if `strict-dynamic` is supported."'nonce-{{nonce}}'","'strict-dynamic'",],'script-src-elem': ["'self'",// fallback value for older browsers, automatically removed if `strict-dynamic` is supported."'nonce-{{nonce}}'",'cdnjs.cloudflare.com','cdn.jsdelivr.net',],'connect-src': SYSTEM_ENV=='development' ? ["'self'",'ws:'] : ["'self'"],'frame-src': ["'self'"],'font-src': ["'self'",'fonts.googleapis.com','cdn.jsdelivr.net','fonts.gstatic.com','data:'],'media-src': ["'self'"],'manifest-src': ["'self'"],'worker-src': ["'self'"],'img-src': ["'self'",'data:','blob:'],},},},
Reproduction
as description
Description
Using the default unsafe-inline in style-src fails OWASP security scans with medium/high risk warnings.
When configuring a stricter CSP by replacing unsafe-inline with nonces:
Unfortunately this is a known limitation of CSP for all JS frameworks, it is totally unrelated to Nuxt Security.
You have two options:
Remove unsafe-inline from style-src to get a perfect OWASP score. To do so, you will first need to eliminate all Javascript code that modifies styles dynamically, which basically eliminates all modern UI frameworks. To be clear: rewrite your UI from scratch without ShadCN and ColorMode, delete all style bindings in VueJS, and rewrite all your dynamic style modifications via CSS selectors.
Accept a slightly lower OWASP score and keep unsafe-inline in style-src. Most people will tell you that the security risk is almost inexistent but you might not want to take this risk.
We filed an RFC proposal on the CSP spec, you can support it here : w3c/webappsec-csp#625
Environment
Nuxt Security Version
v2.2.0
Default setup used?
Yes, the bug happens even if the security option is not customized
Security options
Reproduction
as description
Description
Using the default
unsafe-inline
in style-src fails OWASP security scans with medium/high risk warnings.When configuring a stricter CSP by replacing
unsafe-inline
with nonces:This results in runtime CSP violations like
Additional context
No response
Logs
The text was updated successfully, but these errors were encountered: