Self XSS to Good XSS
A form field on a private HackerOne program reflected an SVG payload that executed as self-XSS, and because the page lacked clickjacking protection, an attacker could trick a victim into copying and pasting the payload to achieve XSS in the victim's browser.
Published on medium.com
#### Arbaz Hussain
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.
What the report shows
The target was a private HackerOne program. The researcher landed on an application form page:
https://sub.site.com/application/request/form
The page contains a form for submitting application details. The researcher entered the following payload into one of the form fields:
'>"/><svg/onload=prompt(document.cookie)>
As soon as the payload was typed into the field, a pop-up appeared, which the researcher labelled Self-XSS.

The image shows the form field with the payload entered and the resulting pop-up.
The important observation was that the form had no X-Frame-Options header and no clickjacking protection. That made it possible to frame the page and turn the self-XSS into an attack against other users.
The proof of concept is a page titled "Poc" that presents a fake game. It holds the payload in a text input and copies it to the clipboard when the input is clicked, then shows an alert. The vulnerable form is loaded in a nearly transparent iframe positioned over the page:
<html><head><title>Poc</title></head><body><h1>Welcome to Click Games</h1>Message :<input id="copy-text" type="text" value='"/><svg/onload=prompt(document.domain)>"'><br><br><br><script>document.getElementById("copy-text").onclick = function(){this.select();document.execCommand('copy');alert("You'r Game Begins!")}</script><style>iframe {width: 600px;height: 450px;position: absolute;top: 0; right: 10;filter: alpha(opacity=50);opacity: 0.1;}</style><iframe src="https://sub.site.com/application/request/form"></iframe></body></html>
The two images show the proof of concept in action: the decoy page with the framed form and the resulting pop-up.
The report rates severity as High, complexity as Easy and weakness as Cross Site Scripting. The report does not describe a fix.
Root cause
The payload containing HTML and an SVG element with an onload handler executed as soon as it was typed into the form field. On its own this is self-XSS: the payload only runs in the browser of the person who typed it, so there is no attacker-controlled path to another user.
The second half of the root cause is the missing framing defence. Because the page could be embedded in an iframe and had no clickjacking protection, an attacker could place the real form under a decoy interface and get a victim to interact with it.
Impact
By combining the reflected payload with clickjacking, the researcher converted a self-XSS into an attack that runs in another user's session. The proof of concept frames the vulnerable form under a decoy page that copies the payload to the clipboard. The researcher states the chain converted the self-XSS into working XSS on other users. The report does not demonstrate theft of session data or any other specific outcome beyond the pop-up.
How this kind of bug works
Self-XSS is a reflection that only the person entering the payload can trigger. It becomes interesting when an attacker can make a victim supply the payload themselves. Two ingredients are needed: a place where user input is rendered as markup, and a way to get the victim to enter and submit that input without realising what it is.
Clickjacking supplies the second ingredient. If a page can be framed, the attacker overlays it with a decoy interface and positions the frame so that the victim's clicks and keystrokes land on the real form. A common pattern is a fake game or "copy this code" prompt that gets the payload into the clipboard, followed by a click that pastes and submits it. The browser treats everything as genuine user interaction with the framed origin, so the script runs there.
The defences are output encoding on the server side so reflected input cannot become markup, and framing controls (X-Frame-Options or a Content-Security-Policy frame-ancestors directive) so the page cannot be embedded by other origins. Clipboard and paste tricks are also mitigated by interfaces that do not accept pasted markup or that sanitise on submission.
How to test for it
- Identify features where input is reflected back into the page: application forms, search boxes, profile fields, error messages, and any parameter echoed into the response.
- Send a benign marker such as a unique string and check where it appears in the response body. Note whether it lands inside HTML text, an attribute, a script block or a URL.
- If the marker is reflected unencoded, try a minimal proof such as an element with an event handler, and confirm execution with a harmless pop-up. Use a value that is unlikely to be filtered, and test different contexts separately.
- Check the response headers for framing protection. If X-Frame-Options or a CSP
frame-ancestorsdirective is missing, the page can be framed. - Build a local proof of concept that frames the page and overlays a decoy, then confirm that a paste-and-submit sequence executes the payload inside the frame.
A positive result is script execution in the framed origin after a simulated victim interaction. Common false positives are reflections that are HTML-encoded, payloads that only execute in the tester's own browser because they were typed directly (true self-XSS with no framing path), and pages that appear framable but are protected by JavaScript frame busting or a CSP that the initial check missed.
How it is fixed
Encode all reflected output according to context, so user input is treated as text and never as markup. Apply framing protection with X-Frame-Options or a CSP frame-ancestors directive that restricts embedding to trusted origins. Where forms accept free text, validate and sanitise on the server side rather than relying on client-side checks. Consider a Content-Security-Policy that blocks inline event handlers, which would stop payloads of this shape even if encoding fails.
Hunting notes
Self-XSS is usually closed as informational, so the value lies in finding the second ingredient. Look for reflected input on pages that also lack framing protection, especially forms that users are likely to interact with: applications, support tickets, feedback and account settings. Recon signals include missing X-Frame-Options and CSP headers across a subdomain, and reflected parameters that survive into the response unencoded.
To make the report land, show the full chain: the reflection, the missing framing defence, and a working proof of concept that demonstrates execution after a victim interaction. Keep the demonstration harmless, use a pop-up rather than anything destructive, and explain clearly why the interaction is realistic. Programs are more likely to accept the report when the impact of script execution in the victim's session is spelled out and the proof does not depend on the tester typing the payload themselves.
What happened, in plain words
A security researcher was testing a private program on HackerOne, a platform where companies invite researchers to look for bugs in their systems. He reached a page on a subdomain that held an application form, where a visitor fills in details and submits them:
https://sub.site.com/application/request/form
A form is just a set of boxes on a web page where you type information and press a button to send it to the server, the computer that runs the website. The interesting question for a tester is what the site does with the text you type. If it later shows that text back on the page, and treats it as part of the page's code rather than as plain text, you can sometimes make the page do things it was never meant to do.
The researcher typed this into one of the form fields:
'>"/><svg/onload=prompt(document.cookie)>
As soon as the text was in the field, a pop-up appeared. A pop-up like this is the classic harmless proof that a browser has run code supplied by someone other than the site's owners. The researcher called this Self-XSS.

The image shows the form field holding the payload and the pop-up that appeared.
Self-XSS means the script only runs in the browser of the person who typed it. That sounds useless: you can always run code in your own browser. The researcher's extra observation is what made the finding valuable. The page sent no X-Frame-Options header and had no clickjacking protection. A header is a small piece of information a server sends alongside a page, and X-Frame-Options is the instruction that tells browsers whether other sites may display that page inside a frame. A frame (or iframe) is a window inside a web page that loads another page. Clickjacking is the trick of putting a real page inside such a window, covering it with a fake interface, and getting a visitor to click or type into the real page without knowing.
Because the form could be framed, the researcher built a decoy page that turned the self-XSS into an attack on other users. That turns a self-XSS into an attack on other users. His proof of concept is a page titled "Poc" that pretends to be a game:
<html><head><title>Poc</title></head><body><h1>Welcome to Click Games</h1>Message :<input id="copy-text" type="text" value='"/><svg/onload=prompt(document.domain)>"'><br><br><br><script>document.getElementById("copy-text").onclick = function(){this.select();document.execCommand('copy');alert("You'r Game Begins!")}</script><style>iframe {width: 600px;height: 450px;position: absolute;top: 0; right: 10;filter: alpha(opacity=50);opacity: 0.1;}</style><iframe src="https://sub.site.com/application/request/form"></iframe></body></html>
Line by line:
- The page shows a heading, "Welcome to Click Games", and a text box labelled "Message :". The box already contains the payload, this time using
prompt(document.domain)instead ofdocument.cookie. - A small script runs when the visitor clicks that text box. It selects the text, copies it to the clipboard with
document.execCommand('copy'), and shows an alert saying "You'r Game Begins!". The visitor thinks a game has started; in reality the dangerous text is now on their clipboard. - The style block makes the iframe 600 by 450 pixels, places it over the page, and sets its opacity to 0.1, so it is almost invisible.
- The iframe loads the vulnerable form from
https://sub.site.com/application/request/form.
The two images show the proof of concept in action: the decoy page with the framed form, and the pop-up that results.
The report rates severity as High, complexity as Easy and the weakness as Cross Site Scripting. It does not describe a fix.
In general, how this kind of bug works
Cross-site scripting, usually shortened to XSS, is what happens when a site takes text from a user and puts it into a page in a way that the browser reads as code. Think of a noticeboard where someone writes "ignore the sign below" and the next reader follows that instruction as if the staff had written it. The browser cannot tell your text from the site's own code, so it obeys both.
Self-XSS is the weakest form: the text only comes back to the person who typed it, so there is no victim yet. It becomes a real bug when an attacker can make someone else supply the text. Two ingredients are needed:
- A place where typed input is shown back on the page as markup, meaning the browser treats it as page structure and code rather than plain characters.
- A way to get a victim to enter and submit that input without realising what it is.
Clickjacking supplies the second ingredient. If a page can be framed, the attacker lays a fake interface over it and lines up the frame so the victim's clicks and keystrokes reach the real form. A fake game or a "copy this code" prompt is a common lure: the payload goes onto the clipboard, and the next click pastes and submits it. The browser sees genuine interaction with the framed site, so the script runs there, in that site's context.
To test for this yourself:
- Find features that echo your input back: application forms, search boxes, profile fields, error messages, any value that reappears in the response.
- Type a harmless unique word and see where it shows up in the page. Is it in ordinary text, inside an attribute, inside a script, or in a URL?
- If it comes back unencoded, try a minimal proof such as an element with an event handler, and confirm with a harmless pop-up. Test each context separately.
- Look at the response headers for framing protection. Without X-Frame-Options or a Content-Security-Policy
frame-ancestorsdirective, the page can be framed. - Build a local proof of concept that frames the page under a decoy, and confirm that a paste-and-submit sequence runs the payload inside the frame.
A positive result is script running in the framed site after a simulated victim interaction. Common false positives are reflections that are properly encoded, payloads that only run because the tester typed them (true self-XSS with no framing path), and pages that look framable but are protected by JavaScript frame busting or a policy the first check missed.
The fixes are output encoding on the server so reflected input can never become markup, and framing controls (X-Frame-Options or a CSP frame-ancestors directive) so other sites cannot embed the page. Validating and sanitising free text on the server, rather than trusting the browser, closes the first gap, and a Content-Security-Policy that blocks inline event handlers stops payloads of this shape even if encoding fails somewhere.
Self-XSS on its own is usually closed as informational, so the value is in finding the second ingredient: reflected input on a page that also lacks framing protection, especially forms people are likely to use, such as applications, support tickets, feedback and account settings. Missing X-Frame-Options and CSP headers across a subdomain are good signals to follow. A report lands best when it shows the whole chain, the reflection, the missing framing defence and a working, harmless proof of concept, and explains why the victim's interaction is realistic.
Glossary
- Self-XSS: XSS that only runs in the browser of the person who typed the payload, with no attacker path to anyone else.
- Payload: the piece of text an attacker supplies to trigger a bug.
- Reflection: when a site sends user input back in the response page.
- Output encoding: converting characters so the browser displays them as text instead of interpreting them as markup.
- Markup: the tags and structure of an HTML page, as opposed to plain text.
- SVG: an image format written in markup, which can carry event handlers such as
onload. - Event handler: an attribute that tells the browser to run code when something happens, such as a page element loading.
document.cookie: the browser's store of cookies for the current page, readable from JavaScript unless protected.document.domain: the hostname of the current page, readable from JavaScript.- Cookie: a small piece of data a site stores in your browser, often used to keep you logged in.
- Header: extra information a server sends with a page, such as security instructions.
- X-Frame-Options: a header that says whether a page may be shown inside a frame on another site.
- CSP (Content-Security-Policy): a header that restricts what a page may load and run; its
frame-ancestorsdirective controls who may frame it. - Iframe (frame): a window inside a web page that loads another page.
- Clickjacking: tricking a visitor into clicking or typing into a real page hidden under a fake interface.
- Frame busting: JavaScript that tries to stop a page from being framed.
- Proof of concept (PoC): a small, harmless demonstration that a bug is real.
- Clipboard: the temporary storage a browser uses when you copy and paste text.
- HackerOne: a platform where organisations invite researchers to report security bugs, sometimes for a reward.
- Bounty: the money a program pays for a valid report.
- Severity: how serious a bug is judged to be.
- Complexity: how hard a bug is to find or exploit.