XSS via JSONP

JSONP (JSON with Padding)

A technique to load cross-origin data before CORS existed.

Works by creating a <script> tag that points to a URL in a web application, e.g.:

The server responds with:

The web page executes it as JS directly on your page, calling myFunction callback.

CSP misconfiguration

  • https://apis.trusted.com JSONP endpoint is trusted by CSP

  • A trusted external script is the following one

  • The server responds with:

XSS

  • The attacker injects the following HTML code:

  • The server responds with:

Last updated