Skip to content
XSS Write-up Intermediate

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.

Mohamed Sayed Follow

Published on flex0geek.blogspot.com

{{media:5}} |

Mohamed Sayed (Flex), on flex0geek.blogspot.com

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

  1. Find that the target reflects the payload and has a CSP allowing trusted third-party domains.
  2. Use a JSONP endpoint on a trusted domain to satisfy the CSP.
  3. Work around the backslash-to-slash issue in the reflected JSON.
  4. Use an iframe srcdoc attribute with URL-encoded content to execute the script.
  5. 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.

More by Mohamed Sayed

View all

9 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.