My First Bug: A Unique $500 XSS.
A reflected cross-site scripting vulnerability existed in an API endpoint that returned JSON data with an HTML content type, allowing HTML injection. An attacker could craft a link that, when visited by a logged-in victim, would execute script in the context of the target domain, though a WAF blocked simple script tags and required a bypass.
One evening after taking a shower, I thought let’s try to find a bug for real now. I opened BurpSuite, turned on some music, and opened a private program’s main domain, which we will call www.target.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.
Context
The target was a private bug bounty program whose main domain the author calls www.target.com. The finding came from the shopping cart flow: a user on www.target.com clicks "Add to Cart", and the front end calls an API on api.target.com to fetch known data about the product being added. The API request carries URL-encoded JSON inside a parameter named param, and the response returns that product data as JSON.
The bug is a reflected XSS in that API response. The response body is JSON, but the Content-Type is set to HTML, and the JSON data is written straight into the HTML document without being wrapped in any tag. That combination turns a data endpoint into an HTML rendering context.
Setup
The researcher used BurpSuite, with the Proxy to intercept traffic and Repeater to replay and modify requests. A testing account on the target was used to log in and drive the cart flow. The program was private, and the work was done in collaboration with the researcher's brother, who joined after the initial finding.
Two preconditions shaped the whole exploitation:
api.target.comis only accessible if theRefererheader is set to a subdomain or domain oftarget.com.- Because the XSS is POST-based and reflected, delivering it from an attacker-owned site would be blocked by the
Originheader check.
Finding it
While intercepting the "Add to Cart" action, the researcher checked Burp history and noticed that before the actual Add to Cart request there was another POST request made through api.target.com. Replaying it in Repeater showed URL-encoded JSON data inside the param parameter, which the API used to return known data about the product being added to the cart.
Some of that data was reflected in the response. The response was JSON, but the Content-Type was HTML. The researcher first assumed the JSON was inside a script tag, which it was not, and attempts to break out of the JSON in that assumed context failed. Once it became clear that the JSON data was printed straight into the HTML document with no surrounding tags, a simple tag was tried:
It was reflected in the response body as expected, and loading the response in the browser confirmed that XSS was possible.

Exploitation
Step 1: confirm reflection of an HTML tag
The param value is URL-encoded JSON. Placing an <h1> tag inside the JSON value and sending the request returned the tag unescaped in the response body, which the browser then parsed as HTML. That confirmed the injection point, but not yet a deliverable exploit, because of the Referer and Origin restrictions on api.target.com.
Step 2: switch POST to GET
A POST-based reflected XSS cannot be triggered by simply sending a victim to a link, and a cross-site POST from an attacker domain would be rejected by the Origin check. The researcher tested whether the POST request could be changed to a GET request, and it worked: the <h1> tag was still reflected with GET. That made the payload linkable.
Step 3: satisfy the Referer check via an open redirect
The remaining obstacle was the Referer requirement. The login flow on account.target.com accepts a redirect parameter:
https://account.target.com/login?redirect=https://account.target.com/home
Putting the vulnerable API link into that redirect parameter produced a link of the form:
https://account.target.com/login?redirect=https://api.target.com/file?param={"data":"<h1>"}
After the victim logs in to their account, account.target.com redirects them to the api.target.com URL, and the browser sends both the Referer and Origin headers set to account.target.com. Both checks pass, and the victim lands on the vulnerable link.

Step 4: bypass the WAF for a script payload
A <script> tag was blocked by the WAF. After roughly 6 hours of attempts, the researcher produced this payload:
<input+type=text+onbeforeinput=location=’https://asd.com'><!--
This requires the victim to type something into the rendered input field before the onbeforeinput handler fires and navigates them to https://asd.com. The researcher judged that a payload needing user interaction like this would probably not have been triaged.

Step 5: the final bypass
The researcher asked their brother for collaboration, shared everything gathered so far, and within 2 hours he found the bypass. The payload:
<%s%v%g+%on%l%oad%=c%o%nf%i%rm%(1%)><!--
The payload was: The final link was:
https://account.target.com/login?redirect=https://api.target.com/file?param={"data":"<%s%v%g+%on%l%oad%=c%o%nf%i%rm%(1%)><!--"}
Root cause
The API on api.target.com returns JSON but sets Content-Type: HTML, and it writes the JSON data into the HTML document without any surrounding tags or output encoding. Because the browser treats the response as HTML, any markup inside the reflected data is parsed and executed. The Referer and Origin checks on the API only restrict who can reach it; they do not sanitise the reflected value, and they were both satisfied by routing the victim through the login redirect on account.target.com. The WAF blocked <script>, but the final payload got past it.
Impact
An attacker who can get a logged-in victim to follow the crafted account.target.com login link can execute JavaScript in the context of api.target.com, after the redirect sets the Referer and Origin headers to account.target.com. The final payload demonstrated execution with confirm(1). The report does not describe any further actions taken with the execution, such as data theft or account takeover.
Fix
The report does not state what the program changed. The appropriate fixes are to serve the API response with a JSON Content-Type rather than HTML, and to encode or reject HTML metacharacters in the reflected param data so that it cannot be parsed as markup. The redirect parameter on account.target.com should also be restricted so it cannot be used to bounce a victim to an arbitrary URL.
Variants to test
- Look for API endpoints that return JSON with an HTML
Content-Typeand reflect a parameter. A positive result is a reflected<h1>appearing unescaped in the response body and rendering in the browser. - Try changing a POST-only reflected endpoint to GET. A positive result is the same reflection over GET, making the payload linkable.
- Look for open redirects on the same registrable domain as the API. A positive result is a redirect that sets
RefererandOriginto the trusted domain when the victim follows it. - When a WAF blocks
<script>, try alternative event-handler vectors such as<svg onload=...>with obfuscated tag and attribute names. A positive result is the handler firing in the browser. - Test whether a payload requiring user interaction, such as an input with
onbeforeinput, is accepted by triage. A positive result is a triaged report, though the researcher expected this would not be.
Outcome
The report was triaged within a day, and the bounty was paid about 5 days after triage. The total payment was $750, split with the researcher's brother, leaving the researcher with $500.


What happened, in plain words
A 14-year-old researcher, working with their brother, found a cross-site scripting (XSS) bug in a private bug bounty program. The program's main website is called www.target.com here. The bug was in the shopping cart: when you click "Add to Cart", the page quietly asks a separate server, api.target.com, for information about the product. That server sent the product information back in a way that a browser treats as a web page, and it copied some of the text the researcher sent straight into that page without cleaning it. So the researcher could put a small piece of HTML (the language web pages are written in) into the request and have the browser run it as code.
Getting a real victim to trigger it took several tricks: changing the request type, using the site's own login redirect to satisfy two security checks, and getting past a web application firewall (WAF, a filter that blocks suspicious requests). The final payload made the browser show a confirm(1) pop-up, which proves code ran. The report was triaged (accepted as valid) in a day, and the bounty was paid about five days later: $750 in total, split with the brother, leaving $500 for the researcher.

The setup, and the words you need
Before the steps, a few everyday ideas. A bug bounty program is a company saying: if you find a security problem in our systems and report it responsibly, we pay you. A private program means only invited researchers can take part. BurpSuite is a tool that sits between your browser and a website so you can see and edit every request and response. Its Proxy records traffic, and its Repeater lets you send the same request again and again with changes.
An API is a server built to answer requests from programs rather than show pages to people. Think of a restaurant: the website is the dining room, the API is the kitchen window where orders go in and dishes come out. Here, the cart page sends an order to api.target.com and gets product data back.
A request is the message your browser sends to a server. A response is the message the server sends back. A header is a small labelled line attached to either one, carrying extra information such as what kind of content is inside. JSON is a simple text format for data, built from names and values in curly braces, like {"data":"..."}. URL-encoded means special characters in that text are swapped for codes so they can travel safely inside a web address.
The vulnerability class is reflected XSS (cross-site scripting). The server takes something you sent and echoes it back inside a page without cleaning it. If what you sent includes HTML tags, the browser obeys them as if the site had written them itself, and tags can carry code. The comparison: a noticeboard where visitors pin notes, and the staff copy your note onto the board word for word. If you write "tear down this board" in the right format, the board's own rules make it happen.
Two headers matter later. The Referer header tells a server which page the request came from. The Origin header tells it which site the request was made by. Servers use them to check that requests come from places they trust.
Finding it
- The researcher opened BurpSuite, turned on music, and opened the private program's main domain,
www.target.com. - They logged into a testing account and clicked one button, "Add to Cart".
- In Burp's history they saw that, just before the actual Add to Cart request, another POST request went to
api.target.com. A POST request is one that sends data to the server, as opposed to a GET request, which mainly asks for something. - They sent that request to Repeater and looked at it. Inside a parameter named
paramthere was URL-encoded JSON. A parameter is a named slot in a request, like a field on a form. This request was fetching known data about the product being added to the cart. - Some of that data came back in the response. The response was JSON, but its
Content-Typeheader said HTML.Content-Typetells the browser what kind of content it is receiving, and so how to treat it. Saying HTML means: render this as a web page.
The researcher first assumed the JSON sat inside a <script> tag in the page, which it did not, and attempts to break out of the JSON on that assumption failed. Then they realised the JSON data was printed straight into the HTML document with no surrounding tags at all. They tried a simple tag:
<h1> is the HTML tag for a large heading. It came back in the response body unescaped, meaning the server did not convert the angle brackets into harmless text. Loading the response in the browser confirmed the heading rendered, so XSS was possible.

Exploitation, step by step
Step 1: confirm an HTML tag comes back
The param value is URL-encoded JSON. Putting <h1> inside the JSON value and sending the request returned the tag unchanged in the response body, and the browser parsed it as HTML. That proved the injection point. It did not yet give a link a victim could click, because of two restrictions on api.target.com:
- The API is only reachable if the
Refererheader is set to a subdomain or domain oftarget.com. - The XSS is POST-based and reflected, so delivering it from a site the attacker owns would be blocked by the
Originheader check.
Step 2: turn POST into GET
A POST-based reflected XSS cannot be triggered by simply sending someone a link, and a cross-site POST from an attacker's domain would be rejected by the Origin check. So the researcher tested whether the POST request could be changed to a GET request. It worked: the <h1> tag was still reflected over GET. That made the payload linkable, because a GET request can live entirely inside a URL.
Step 3: use the login redirect to satisfy the Referer check
The remaining obstacle was the Referer requirement. The login flow on account.target.com accepts a redirect parameter:
https://account.target.com/login?redirect=https://account.target.com/home
Read it as: the login page, with a slot called redirect whose value is the page to go to afterwards. Normally that value is the site's own home page. Putting the vulnerable API link into that slot produced a link of the form:
https://account.target.com/login?redirect=https://api.target.com/file?param={"data":"<h1>"}
After the victim logs in to their account, account.target.com redirects them to the api.target.com URL. Because the browser followed a redirect from account.target.com, it sends both the Referer and Origin headers set to account.target.com. Both checks pass, and the victim lands on the vulnerable link. The login flow's redirect parameter took the API link as its value.

Step 4: get past the WAF
A <script> tag was blocked by the WAF, the filter that inspects requests and refuses suspicious ones. After roughly 6 hours of attempts, the researcher produced this payload:
<input+type=text+onbeforeinput=location=’https://asd.com'><!--
Line by line in plain words: <input starts a text box; type=text makes it a normal text field; onbeforeinput=location=’https://asd.com' attaches an instruction that runs when the victim starts typing, sending the browser to https://asd.com; the + signs stand in for spaces; and <!-- starts an HTML comment, which hides whatever comes after it in the response. This payload needs the victim to type something into the box before anything happens. The researcher judged that a payload requiring that interaction would probably not have been triaged.

Step 5: the final bypass
The researcher brought in their brother, shared everything gathered so far, and within 2 hours he found the bypass. The payload:
<%s%v%g+%on%l%oad%=c%o%nf%i%rm%(1%)><!--
The payload was: The handler is c%o%nf%i%rm%(1%), which the browser reads as confirm(1), a pop-up showing the number 1. The trailing <!-- comments out the rest of the response. The final link was:
https://account.target.com/login?redirect=https://api.target.com/file?param={"data":"<%s%v%g+%on%l%oad%=c%o%nf%i%rm%(1%)><!--"}
Why it worked
The API on api.target.com returns JSON but sets Content-Type: HTML, and it writes the JSON data into the HTML document with no surrounding tags and no output encoding. Output encoding means converting characters like < and > into harmless text so the browser shows them instead of obeying them. Because the browser treats the response as HTML, any markup inside the reflected data is parsed and executed. The Referer and Origin checks only restrict who can reach the API; they do not clean the reflected value, and both were satisfied by routing the victim through the login redirect on account.target.com. The WAF blocked <script>, but the final payload got past it.
What an attacker could do
An attacker who gets a logged-in victim to follow the crafted account.target.com login link can run JavaScript in the context of api.target.com, after the redirect sets the Referer and Origin headers to account.target.com. The final payload demonstrated execution with confirm(1). The report does not describe any further actions taken with that execution, such as stealing data or taking over an account.
How to fix it
The report does not state what the program changed. The appropriate fixes are to serve the API response with a JSON Content-Type rather than HTML, and to encode or reject HTML metacharacters in the reflected param data so it cannot be parsed as markup. The redirect parameter on account.target.com should also be restricted so it cannot bounce a victim to an arbitrary URL.
Things to try on other targets
- Look for API endpoints that return JSON with an HTML
Content-Typeand reflect a parameter. A positive result is a reflected<h1>appearing unescaped in the response body and rendering in the browser. - Try changing a POST-only reflected endpoint to GET. A positive result is the same reflection over GET, making the payload linkable.
- Look for open redirects on the same registrable domain as the API. A positive result is a redirect that sets
RefererandOriginto the trusted domain when the victim follows it. - When a WAF blocks
<script>, try alternative event-handler vectors such as<svg onload=...>with obfuscated tag and attribute names. A positive result is the handler firing in the browser. - Test whether a payload requiring user interaction, such as an input with
onbeforeinput, is accepted by triage. A positive result is a triaged report, though the researcher expected this would not be.
Outcome
The report was triaged within a day, and the bounty was paid about 5 days after triage. The total payment was $750, split with the researcher's brother, leaving the researcher with $500.


Glossary
- API: a server built to answer requests from programs rather than show pages to people.
- Bug bounty program: a company paying researchers to find and report security problems responsibly.
- BurpSuite: a tool that sits between browser and website so you can see and edit requests and responses.
- Content-Type: a header telling the browser what kind of content it is receiving, and so how to treat it.
- Cross-site scripting (XSS): a bug where a site lets attacker-supplied content run as code in a victim's browser.
- GET: a request type that mainly asks for something, and can live entirely inside a URL.
- Header: a small labelled line attached to a request or response carrying extra information.
- HTML: the language web pages are written in, built from tags like
<h1>. - JSON: a simple text format for data, built from names and values in curly braces.
- Open redirect: a redirect that will send a visitor to any address you name.
- Origin: a header telling a server which site a request was made by.
- Output encoding: converting characters like
<and>into harmless text so the browser shows them instead of obeying them. - Parameter: a named slot in a request, like a field on a form.
- POST: a request type that sends data to the server.
- Private program: a bug bounty program open only to invited researchers.
- Proxy: the part of BurpSuite that records and lets you edit traffic between browser and site.
- Referer: a header telling a server which page a request came from.
- Reflected XSS: XSS where the server echoes your input back inside a page without cleaning it.
- Repeater: the part of BurpSuite that replays and modifies a single request.
- Request: the message your browser sends to a server.
- Response: the message a server sends back.
- Triage: the step where a program reviews a report and accepts it as valid.
- URL-encoded: special characters swapped for codes so they can travel safely inside a web address.
- WAF (web application firewall): a filter that inspects requests and refuses suspicious ones.