Bypassing CSP is not enough to gain your XSS
A reflected cross-site scripting payload was blocked by a Content Security Policy, but the author found a way around it by loading a JSONP endpoint on a trusted domain and using an iframe srcdoc attribute to execute script. This allowed arbitrary JavaScript to run despite the CSP.
Published on flex0geek.blogspot.com
{{media:5}} |
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the page reflected user input into an HTML response and the CSP allowed script sources on third-party domains that host JSONP endpoints, so the policy could be bypassed.
Impact
An attacker could execute arbitrary JavaScript in the victim's browser despite the CSP, though the text does not show a full end-to-end exploit against a live victim.
What the attacker needed
Reflected input on the target; CSP trusts a JSONP-capable domain
How it was found
- Find that the target reflects the payload and has a CSP allowing trusted third-party domains.
- Use a JSONP endpoint on a trusted domain to satisfy the CSP.
- Work around the backslash-to-slash issue in the reflected JSON.
- Use an iframe srcdoc attribute with URL-encoded content to execute the script.
- Load a vulnerable AngularJS from a trusted CDN to run custom JavaScript.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A Content Security Policy (CSP) is a browser rule that says which scripts a page may load, so it can stop injected scripts from running. Here the page still reflected user input, and the author found a trusted script source plus an iframe trick to get code to run anyway.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.