Cloudflare WAF Bypass → DOM-Based XSS via Unsanitized iframe.src
A URL parameter was decoded and assigned directly to an iframe's src attribute without protocol validation, allowing a JavaScript URI to execute in the target origin. A tab character between the protocol name and colon bypassed the WAF's filtering, enabling same-origin XSS.
Published on medium.com
Bug Bounty
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 starting point was an endpoint at /girls that accepts a parameter named whatsAppReturn alongside isWhatsApp=1. The name suggests the value is a URL used to redirect or embed a WhatsApp-related destination, The name suggested the value might be a URL used for redirecting or embedding a WhatsApp-related destination..
The write-up does not name the program or the product beyond the endpoint and parameter. What it does describe is the full path the value takes: it is reflected into server-rendered application state, consumed during client-side hydration of a single-page application, decoded with decodeURIComponent, and finally assigned to an iframe's src attribute. Because that assignment happens without protocol validation, the parameter becomes a JavaScript URL execution primitive in the target's origin.
The interesting part of the finding is not the sink itself but the filter behaviour: a straightforward javascript: payload was blocked, while an equivalent representation using a tab character survived and still executed in the browser. The final result was arbitrary JavaScript execution in the target's origin, and the impact was deliberately narrowed to that after testing showed the primary authentication cookie was HttpOnly.
Setup
The write-up does not describe any accounts, roles, tooling versions or special preconditions. The important discovery was inside the production JavaScript bundle, and the browser's developer tools were used. The only stated interaction with tooling is opening DevTools with F12 and using the Console to inspect the hydrated page and check for the execution marker.
Finding it
The starting point was the endpoint:
/girls
with the parameters:
isWhatsApp=1whatsAppReturn=<value>
The parameter name stood out because it suggested a URL used for redirecting or embedding a WhatsApp-related destination. The researcher's habit with parameters that sound like return, redirect, url, next, callback, target, continue or destination is to ask where the value eventually ends up. A parameter that is harmless in one context becomes dangerous if it reaches a sink such as:
location =window.open(...)iframe.src =script.src =element.innerHTML =element.setAttribute(...)
So rather than focusing only on the HTTP response, the value was followed through the application's JavaScript. The important discovery was inside the production JavaScript bundle, where the application eventually performed:
iframe.setAttribute('src', decodeURIComponent(whatsAppReturn))
That line raised four questions, each answered in the write-up:
- Is the value controlled by the attacker? Yes, it is supplied directly through the URL.
- Is it decoded before reaching the sink? Yes, through
decodeURIComponent(...). - Is there protocol validation? No validation was visible before the value reached the iframe.
- Can an iframe
srccontain a dangerous URI scheme? Yes.
The resulting data flow is:
Attacker-controlled URL ↓whatsAppReturn ↓decodeURIComponent() ↓iframe.setAttribute("src", ...) ↓browser interprets URI ↓JavaScript execution
At that point there was a potential XSS sink, which the write-up treats as only the beginning of the work.
Exploitation
Step 1: Test the obvious payload
The first test was the obvious JavaScript URI, conceptually:
javascript:<payload>
The application or WAF did not allow the straightforward representation. Rather than asking why the payload did not work, the researcher asked which layer was stopping it. The write-up lists the layers that can independently reject or accept a payload:
Request ↓CDN / WAF ↓Server ↓SSR state ↓Client-side JavaScript ↓DOM ↓Browser parser
A payload can be rejected by one layer while remaining completely valid to another.
Step 2: Look for a parser differential
The breakthrough came from considering how browsers parse whitespace and how security filters detect dangerous protocols. The application was ultimately interested in the decoded URI, so instead of relying on a literal javascript: the researcher tested an encoded control character between the protocol name and the colon. The working proof used a tab character:
java%09script:
The resulting PoC showed that the browser ultimately interpreted the value as an executable JavaScript URI. The broader lesson is that WAFs and browsers may normalise input differently:
Attacker input ↓WAF normalization ↓Application decoding ↓DOM assignment ↓Browser URL parsing
If those components disagree about normalisation, security controls can sometimes be bypassed, which is why testing only the canonical payload is often insufficient.
Step 3: Build a minimal proof of execution
A minimal proof was used rather than immediately attempting credential theft. The PoC concept was:
/girls?isWhatsApp=1&whatsAppReturn=<encoded-JavaScript-URI>
The JavaScript changed a harmless browser-controlled property so execution could be verified without accessing or transmitting sensitive information. The proof assigned a value to a property on the top-level window, and the observed result was equivalent to:
top.__SC_WA_CF_PWN_535 = 1
Checking the property:
window.__SC_WA_CF_PWN_535
returned:
That gave a clean execution primitive.
Step 4: Confirm it is really XSS
The write-up lists five independent pieces of evidence:
- Server-side reflection: the supplied value appeared inside the server-rendered application state.
- Client-side hydration: the SPA consumed that state during hydration.
- DOM sink: the value was assigned to an iframe with
iframe.setAttribute('src', ...). - Browser execution: the iframe interpreted the resulting URI as JavaScript.
- Same-origin context: the resulting JavaScript executed in the target origin rather than an attacker-controlled origin.
The last point is what makes it a meaningful XSS vulnerability, because the security boundary crossed is:
Attacker-controlled input ↓Target application ↓Target-origin JavaScript execution
Step 5: Reproduce it cleanly
The write-up gives a reproduction methodology that starts with a harmless execution marker.
- Open the vulnerable endpoint:
/girls?isWhatsApp=1&whatsAppReturn=<PoC>
- Open DevTools:
F12 → Console
-
Inspect the hydrated page and look for the iframe generated by the application. The important observation is that the attacker-controlled value reaches the iframe's
src. -
Wait for hydration: the vulnerable DOM operation occurs as the client application initialises.
-
Verify execution by checking the harmless marker created by the PoC. If the marker exists in the top-level window, JavaScript execution has been demonstrated.
Step 6: Test the real impact
After confirming XSS, the next question was what it can actually do. The first assumption was that JavaScript execution might allow direct session theft and therefore account takeover. The browser storage and cookie environment was tested. The application exposed several interesting client-side values, including identifiers and application/analytics tokens, but the primary authentication cookie was protected with HttpOnly, so:
document.cookie
could not retrieve the primary session cookie. The write-up states the conclusion plainly:
XSS ≠ automatically Account Takeover
The confirmed findings were:
Confirmed: Arbitrary JavaScript execution Same-origin XSS DOM manipulation User interaction abuse potential
and the unconfirmed ones were:
Not confirmed: Direct theft of the primary HttpOnly session cookie Full account takeover
Step 7: Explore realistic capabilities and drop the weak ones
During testing the researcher experimented with multiple impact scenarios, including token collection, keyboard-event monitoring, DOM modification, form interaction and phishing-style UI replacement. The realisation was that demonstrating a capability is not the same as proving a practical exploit chain. Registering a key handler is different from reliably capturing a victim, which requires realistic victim interaction and browser behaviour. The program ultimately determined that the demonstrated keylogging scenario required unrealistic interaction and was not a sufficient reason to increase severity, which the write-up calls a fair assessment.
Root cause
The mistake is the direct assignment of an attacker-controlled value to a URL-valued DOM sink without protocol validation:
iframe.setAttribute('src', decodeURIComponent(whatsAppReturn))
The value is decoded with decodeURIComponent and then handed to the browser, which parses it as a URI and executes it when the scheme is JavaScript. No validation of the scheme was visible before the value reached the iframe.
The existing defence did not stop it because the WAF and the browser normalise input differently. The WAF saw the encoded representation and accepted the request, while the application decoded the value and the browser parsed the decoded result as an executable URI. The successful path was conceptually:
Encoded attacker input ↓WAF sees unusual representation ↓Request accepted ↓Application decodes value ↓iframe receives decoded value ↓Browser parses URI ↓JavaScript executes
The write-up stresses that a WAF generally sees a request while the browser ultimately executes a parsed URL, and that these are two different environments. Blocking javascript: at the WAF does not make the functionality safe.
Impact
A crafted /girls URL with isWhatsApp=1 and a malicious whatsAppReturn value results in arbitrary JavaScript execution in the target's origin. Because the script runs same-origin, it can manipulate the DOM, replace or inject content, redirect the victim, perform actions available to the victim's browser context, interact with forms and observe or manipulate DOM state, and read non-HttpOnly browser storage such as localStorage, sessionStorage and non-HttpOnly cookies, depending on what the application stores there.
The impact does not extend to direct theft of the primary session cookie, which is HttpOnly, and full account takeover was not demonstrated. The program also judged the demonstrated keylogging scenario to require unrealistic interaction. The final severity was reduced from High to Low, and the bounty received was $200.
Fix
The primary fix is to avoid assigning attacker-controlled values directly to a URL-valued DOM sink. The recommended measures are:
- Validate the protocol and only permit expected schemes, for example
https:. - Prefer an allowlist: if the application expects a specific set of domains, validate both
schemeandhostname. - Reject dangerous schemes after decoding. Validation must happen after all relevant decoding steps, otherwise this pattern still bypasses the protection:
encoded input ↓validation ↓decode ↓dangerous URI
- Avoid unnecessary dynamic iframe URLs: if the functionality does not require arbitrary URLs, do not allow arbitrary URLs.
- Use defence in depth: CSP should complement input validation rather than being relied upon as the only defence.
The write-up also notes that developers sometimes treat iframe URLs as inherently safe because they are "just URLs", which is dangerous because a URL-valued DOM property is still interpreted by a browser parser. An application expecting HTTPS URLs should enforce an allowlist such as https: rather than accepting arbitrary URI schemes.
Variants to test
- Other URL-like parameters. Look for parameters named
return,redirect,next,url,targetorcallbackand trace them into the JavaScript bundle. A positive result is a value that reaches a sink such aslocation =,window.open(...),iframe.src =,script.src =,element.href =,element.setAttribute(...)orelement.innerHTML =without scheme validation. - Decoding functions before the sink. Search bundles for
decodeURIComponent,decodeURI,atobandJSON.parse. A positive result is a value that is decoded after the WAF has inspected it and before it reaches a URL or HTML sink. - Whitespace and control characters inside the scheme. Try encoded tabs, newlines and other whitespace between the protocol name and the colon, as in
java%09script:. A positive result is a request the WAF accepts whose decoded value the browser still treats as a JavaScript URI. - Encoding and normalisation mismatches. Test URL encoding, double encoding, mixed case, Unicode normalisation and HTML entity decoding. A positive result is any representation that passes the filter but is normalised by the browser into an executable scheme.
- Dangerous schemes beyond JavaScript. Conceptually test whether the application accepts schemes such as
javascript:anddata:in the same sink. A positive result is a sink that accepts either scheme without an allowlist. - Storage exposure after execution. Once same-origin execution is proven, enumerate
localStorage,sessionStorageand cookies, and check which cookies carryHttpOnly,SecureandSameSite. A positive result is sensitive application data readable from JavaScript, or an authentication cookie that is notHttpOnly. - Impact claims. For every capability you demonstrate, check whether it needs realistic victim interaction before claiming severity. A positive result for a stronger claim is a chain that works under normal browser behaviour, not one that only works with contrived interaction.
What happened, in plain words
A website had a page that took a web address from the visitor and put it inside a small embedded window on the page. The person who found the bug realised that if you put a special kind of address in there, the browser would not just load a page: it would run code. That is the bug class called cross-site scripting, or XSS.
The site's protective filter (a web application firewall, or WAF) did not allow the obvious version of the attack. But a slightly different spelling of the same thing, using an invisible tab character, slipped past the filter and still ran in the browser. The researcher proved the code ran by setting a harmless marker value, then tested the browser storage and cookie environment. The main login cookie turned out to be protected in a way that JavaScript cannot read, so the claim was reduced from "full account takeover" to "confirmed XSS". The program accepted it, lowered the severity from High to Low, and paid $200.
This article walks through the whole investigation from zero. You only need a browser and a computer to follow along.
The words you need first
Before the steps, a few everyday comparisons for the concepts that come up again and again.
- Endpoint: a specific address on a website that does one job, like a counter in a shop.
/girlsis an endpoint. - Parameter: extra information attached to an address, like a note on an order form. In a URL, parameters come after a
?and look likename=value. - iframe: a small window embedded inside a web page that shows another page. Think of a picture frame hanging on a wall: the wall is the main page, the picture inside the frame is separate content.
srcattribute: the "source" setting of an iframe, the address of what should be shown inside the frame.- JavaScript: the programming language that browsers run. It is what makes pages interactive.
- DOM: the browser's live model of the page, a tree of every element. When JavaScript changes the page, it changes the DOM.
- Sink: a place in code where data ends up being used in a way that can be dangerous, like a drain. If untrusted data reaches a sink, trouble can follow.
- XSS (cross-site scripting): a bug where an attacker gets their own JavaScript to run inside someone else's website, in the victim's browser. The script then acts as if it belonged to that site.
- WAF (web application firewall): a filter that sits in front of a website and inspects incoming requests, blocking ones that look like attacks. Like a bouncer at a door checking IDs.
- Cookie: a small piece of data a website asks the browser to store and send back on every request. Often used to remember that you are logged in.
HttpOnly: a setting on a cookie that tells the browser "JavaScript must never be allowed to read this". It is a lock on the cookie jar.- Token: a value that stands in for something else, often a proof of identity or a key to an API.
- API: a way for one piece of software to talk to another, like a service counter where you hand over a request and get an answer back.
- URL encoding: writing special characters in a URL in a safe form. A space becomes
%20, for example.%09is a tab character. - Decoding: turning encoded text back into its original characters.
- Normalisation: different systems tidying up input in slightly different ways before using it. If two systems tidy differently, they can disagree about what the input means.
- Parser differential: when two components (say a WAF and a browser) read the same input and come to different conclusions about it. This is the heart of the bug.
- Same-origin: JavaScript running with the same website identity as the page it is on. Same-origin code can read that site's data; code from another site cannot.
- Account takeover (ATO): an attacker gaining control of someone else's account.
- CSP (Content Security Policy): a set of rules a website can send to the browser saying which scripts are allowed to run.
- PoC (proof of concept): the smallest demonstration that a bug is real.
1. The starting point
The researcher found an endpoint:
/girls
This is a path on the website. When you visit it, the site shows a page. The page accepts parameters:
isWhatsApp=1whatsAppReturn=<value>
Read this as two separate parameters joined together in the write-up's formatting: isWhatsApp=1 and whatsAppReturn=<value>. The first is a parameter named isWhatsApp set to 1. The second is a value the visitor supplies.
The name whatsAppReturn is a clue. It sounds like "where to return to after a WhatsApp step", which means it probably holds a web address. Parameters with names like return, redirect, url, next, callback, target, continue or destination all suggest the same thing: a URL that the site will use somewhere.
Why does that matter? Because a value that is harmless in one place becomes dangerous in another. The write-up lists places where a URL-like value can end up:
location =window.open(...)iframe.src =script.src =element.innerHTML =element.setAttribute(...)
Each of these is a sink. location = navigates the page. window.open(...) opens a new window. iframe.src = loads something into an embedded frame. script.src = loads a script file. element.innerHTML = writes HTML into the page. element.setAttribute(...) sets any attribute on any element.
So instead of only looking at what the server sends back, the researcher followed the value into the site's JavaScript. That is the key habit: ask where the value goes, not just what the response looks like.
2. Tracing the data flow
The site's JavaScript is delivered as a bundle, a single large file containing all the code the page needs. Inside that bundle, the researcher found this line:
iframe.setAttribute('src', decodeURIComponent(whatsAppReturn))
Line by line:
iframeis the embedded frame element on the page..setAttribute('src', ...)sets the frame's source address to whatever comes next.decodeURIComponent(...)takes the text and turns any URL-encoded characters back into their real form. So%20becomes a space,%09becomes a tab, and so on.whatsAppReturnis the value the visitor supplied in the URL.
In plain words: "take whatever the visitor typed, decode it, and use it as the address of the embedded frame".
That raised four questions, and the write-up answers each one:
- Is the value controlled by the attacker? Yes. It comes straight from the URL, so anyone can put anything there.
- Is it decoded before reaching the sink? Yes, by
decodeURIComponent(...). - Is there protocol validation? No validation was visible before the value reached the iframe. Nothing checked whether the address was a normal web address or something else.
- Can an iframe
srccontain a dangerous URI scheme? Yes. A browser will happily treat certain schemes as instructions rather than addresses.
The data flow, drawn out:
Attacker-controlled URL ↓whatsAppReturn ↓decodeURIComponent() ↓iframe.setAttribute("src", ...) ↓browser interprets URI ↓JavaScript execution
Read the arrows as "then goes to". The attacker's URL becomes the parameter, gets decoded, gets set as the frame's source, gets read by the browser, and the browser runs it as code.
At this point there is a potential XSS sink. But finding a sink is only the beginning: you still have to prove it actually executes.
3. Testing the obvious payload
The first test was the obvious one, a JavaScript URI:
javascript:<payload>
A URI is just an address. Most start with http: or https:. The javascript: scheme is different: instead of pointing at a page, it tells the browser "run the text after the colon as code". So javascript:alert(1) would pop up an alert box.
The site, or its WAF, did not allow the straightforward version.
Here is where the mindset matters. Instead of asking "why doesn't my payload work?", the researcher asked "which layer is stopping it?". A request passes through several layers before anything runs:
Request ↓CDN / WAF ↓Server ↓SSR state ↓Client-side JavaScript ↓DOM ↓Browser parser
- Request: the browser sends the URL to the site.
- CDN / WAF: a content delivery network and firewall sit in front and inspect the request.
- Server: the site's backend builds a response.
- SSR state: server-side rendering means the server produces the initial HTML, including a snapshot of data the page will need. That snapshot is the "state".
- Client-side JavaScript: the page's own code runs in the browser and takes over.
- DOM: the browser's live model of the page gets updated.
- Browser parser: the browser reads the final value and decides what it means.
A payload can be rejected by one layer while remaining completely valid to another. That is the gap the researcher went looking for.
4. Looking for a parser differential
The breakthrough came from thinking about two things at once: how browsers read whitespace, and how filters detect dangerous protocols.
The application ultimately cares about the decoded URI. So instead of a literal javascript:, the researcher put an encoded control character between the protocol name and the colon. The working proof used a tab character:
java%09script:
What this means:
javaandscriptare the two halves of the wordjavascript.%09is URL encoding for a tab character.- When the browser decodes this, it sees
java, a tab, thenscript:. Browsers tolerate whitespace inside a scheme name, so they still read it asjavascript:. - A filter that looks for the literal string
javascript:does not see that string, because the tab is in the middle.
The resulting PoC showed that the browser ultimately interpreted the value as an executable JavaScript URI.
The broader lesson is that WAFs and browsers may normalise input differently:
Attacker input ↓WAF normalization ↓Application decoding ↓DOM assignment ↓Browser URL parsing
Each arrow is a place where the text can be tidied up in a different way. If those components disagree about normalisation, security controls can sometimes be bypassed. That is why testing only the canonical payload is often insufficient: the canonical payload is exactly what the filter was built to catch.
5. The working proof of concept
A minimal proof was used rather than immediately attempting credential theft. This is a deliberate choice: prove the bug exists without touching anything sensitive.
The PoC concept was:
/girls?isWhatsApp=1&whatsAppReturn=<encoded-JavaScript-URI>
This is the full URL a victim would open. The ? starts the parameters, & separates them, and the second one carries the encoded JavaScript URI.
The JavaScript changed a harmless browser-controlled property so execution could be verified without accessing or transmitting sensitive information. The proof assigned a value to a property on the top-level window, and the observed result was equivalent to:
top.__SC_WA_CF_PWN_535 = 1
topmeans the outermost window of the page, the one the user sees..__SC_WA_CF_PWN_535is a made-up property name. It is just a label.= 1sets it to the number one.
If the injected code ran, that property would exist. If it did not run, the property would be missing.
Checking the property:
window.__SC_WA_CF_PWN_535
returned:
That gave a clean execution primitive: a reliable, repeatable way to make the browser run code from the attacker's input.
6. Why this was definitely XSS
The write-up lists five independent pieces of evidence. Each one rules out a different "maybe it was something else" explanation.
- Server-side reflection: the supplied value appeared inside the server-rendered application state. The server was echoing the input back into the page.
- Client-side hydration: the SPA (single-page application) consumed that state during hydration. Hydration is when the page's JavaScript wakes up and takes over the HTML the server sent, attaching behaviour to it.
- DOM sink: the value was assigned to an iframe with
iframe.setAttribute('src', ...). That is the dangerous line from earlier. - Browser execution: the iframe interpreted the resulting URI as JavaScript. The browser, not the server, did the running.
- Same-origin context: the resulting JavaScript executed in the target origin rather than an attacker-controlled origin. This is the crucial one.
Why does same-origin matter so much? Because it decides what the code is allowed to touch. The security boundary crossed is:
Attacker-controlled input ↓Target application ↓Target-origin JavaScript execution
The input came from the attacker, but the code ran as if it belonged to the target site. That is what makes it a meaningful XSS vulnerability, rather than just "my URL caused JavaScript somewhere to execute".
7. The reproduction methodology
The cleanest way to reproduce the issue is to start with a harmless execution marker. Here is the step-by-step.
Step 1: Open the vulnerable endpoint.
/girls?isWhatsApp=1&whatsAppReturn=<PoC>
Paste this into the address bar with your own harmless PoC in place of <PoC>. The point is to load the page with the malicious value in the parameter.
Step 2: Open DevTools.
F12 → Console
DevTools are the browser's built-in inspection tools. Pressing F12 opens them. The Console tab is where you can type JavaScript and see results.
Step 3: Inspect the hydrated page.
Look for the iframe generated by the application. The important observation is that the attacker-controlled value reaches the iframe's src. You can see this in the Elements panel or by asking the Console about the frame.
Step 4: Wait for hydration.
The vulnerable DOM operation occurs as the client application initialises. In other words, the dangerous line runs when the page's JavaScript starts up, not when the server sends the HTML. Give it a moment.
Step 5: Verify execution.
Check the harmless marker created by the PoC. If the marker exists in the top-level window, JavaScript execution has been demonstrated. That is the whole proof: a value you set, appearing where only code could have set it.
8. The interesting part: Cloudflare wasn't the actual fix
One of the biggest lessons from this investigation was not to confuse:
WAF blocked payload
with:
application is secure
A WAF generally sees a request. The browser ultimately executes a parsed URL. Those are two different environments, and they can disagree.
The successful path looked conceptually like:
Encoded attacker input ↓WAF sees unusual representation ↓Request accepted ↓Application decodes value ↓iframe receives decoded value ↓Browser parses URI ↓JavaScript executes
Read it as a relay race. The WAF looks at the baton and decides it is fine. The application then transforms the baton. The browser receives the transformed version and acts on it. The WAF never saw what the browser saw.
This is a classic example of why parser differentials are worth testing. Whenever a WAF blocks javascript:, do not immediately conclude that the functionality is safe. Instead investigate:
- URL encoding
- double encoding
- whitespace
- tabs
- newlines
- mixed case
- Unicode normalization
- HTML entity decoding
- application-specific decoding
- browser URL normalization
The key is to understand which transformation happens at which layer. If you know that, you know where the gaps are.
9. Testing the real impact
After confirming XSS, the next question was: what can this actually do?
This is where the researcher initially made an important mistake. The first assumption was that JavaScript execution might allow direct session theft and therefore account takeover. Session theft means stealing the cookie that proves you are logged in, then using it to act as you.
So the browser storage and cookie environment was tested. The application exposed several interesting client-side values, including identifiers and application/analytics tokens.
However, the primary authentication cookie was protected using HttpOnly. That meant:
document.cookie
could not retrieve the primary session cookie. document.cookie is the JavaScript way to read cookies. With HttpOnly set, the browser simply hides that cookie from JavaScript, no matter what code runs on the page.
Therefore:
XSS ≠ automatically Account Takeover
This is a critical bug bounty lesson. XSS is serious, but its impact depends on what the code can actually reach. If the login cookie is locked away, the attacker cannot simply copy it and log in as the victim.
10. Don't overclaim your impact
Initially, the vulnerability appeared to be an account-takeover issue. After testing the actual authentication mechanism, that conclusion was not supported.
The correct conclusion was:
Confirmed: Arbitrary JavaScript execution Same-origin XSS DOM manipulation User interaction abuse potential
and the unconfirmed ones were:
Not confirmed: Direct theft of the primary HttpOnly session cookie Full account takeover
- Arbitrary JavaScript execution: the attacker can run any code they like in the page.
- Same-origin XSS: that code runs with the site's identity.
- DOM manipulation: the code can change the page.
- User interaction abuse potential: the code can try to trick the user into doing things.
- Direct theft of the primary HttpOnly session cookie: not possible here, because of
HttpOnly. - Full account takeover: not demonstrated.
This distinction matters enormously when writing reports. A strong report says "I confirmed X". A weak report says "I think this could probably lead to X". The second statement can reduce confidence in the entire report, because the reader starts wondering which other claims are guesses.
In this case, the final report was corrected to reflect the actual evidence.
11. What the XSS can realistically enable
Even without access to the primary authentication cookie, same-origin XSS remains security-relevant. Depending on the application's functionality and user interaction, an attacker-controlled script could potentially do several things.
Modify the page.
DOM manipulationUI replacementcontent injection
The script can change what the user sees: swap the interface, inject content, or replace a form with a fake one.
Redirect the victim.
An attacker could replace or manipulate the page content and navigation flow, sending the user somewhere else.
Perform actions in the victim's browser.
JavaScript executes with the application's origin, meaning application functionality exposed to that browser context may become accessible. In plain words: anything the site lets a logged-in user do through the browser, the script can try to do too, because the browser thinks the script is part of the site.
Interact with forms.
If sensitive information is entered into a page controlled by the application, malicious JavaScript may be able to observe or manipulate that DOM state.
Access non-HttpOnly browser storage.
Depending on the application's implementation:
localStoragesessionStoragenon-HttpOnly cookies
may contain useful application data. localStorage and sessionStorage are two browser storage areas for web pages. localStorage persists until cleared; sessionStorage lasts until the tab closes. Neither is protected by HttpOnly, so JavaScript can read them.
The exact impact must always be tested rather than assumed.
12. A mistake that taught me a lot
During testing the researcher experimented with multiple impact scenarios. Some included:
- token collection
- keyboard-event monitoring
- DOM modification
- form interaction
- phishing-style UI replacement
The important realisation was that demonstrating a capability is not the same as proving a practical exploit chain. For example:
Can JavaScript register a key handler?
is different from:
Can an attacker reliably capture a victim
A key handler is code that listens for keystrokes. Registering one is trivial. Actually capturing a victim's typing reliably requires the victim to be on the right page, in the right state, with the right interaction, and the browser to behave in a particular way. The second requires realistic victim interaction and browser behaviour.
The program ultimately determined that the demonstrated keylogging scenario required unrealistic interaction and was not a sufficient reason to increase severity. That was a fair assessment.
13. The better bug bounty mindset
This finding reinforced several habits that the researcher now considers extremely important.
Don't stop at reflection. Reflection alone isn't the vulnerability. Just because your input appears in the page does not mean it runs. Trace:
Input ↓Transformation ↓Sink ↓Parser ↓Execution
Each arrow is a question: what happens to the value here? Does it get decoded? Does it reach a dangerous place? How does the browser read it? Does it actually run?
Don't stop when the WAF blocks you. A blocked payload is a signal to investigate the parsing chain. Ask: does the application and browser interpret this input the same way the WAF does?
Understand every decoding step. Here, this line was particularly important:
decodeURIComponent(whatsAppReturn)
If you see any of these:
encodeURIComponentdecodeURIComponentatobdecodeURIJSON.parseDOMParserinnerHTMLsetAttribute
slow down and investigate the transformations. encodeURIComponent and decodeURIComponent convert between plain text and URL-encoded text. atob decodes base64. decodeURI is a similar decoding function. JSON.parse turns text into a data object. DOMParser turns text into a page structure. innerHTML and setAttribute write into the page. Every transformation is a potential place for assumptions between security controls to break.
14. A practical XSS hunting workflow
When hunting modern JavaScript applications, the researcher's workflow is roughly:
1. Discover interesting parameters ↓2. Identify URL/redirect/callback parameters ↓3. Search JavaScript bundles ↓4. Trace attacker-controlled data ↓5. Identify DOM sinks ↓6. Determine every decoding/normalization step ↓7. Test harmless payloads ↓8. Identify filtering/WAF behavior ↓9. Test parser differentials ↓10. Prove same-origin execution ↓11. Determine realistic impact ↓12. Remove unsupported claims ↓13. Submit minimal reproducible PoC
In plain words:
- Find parameters that look interesting.
- Focus on ones that sound like URLs or redirects.
- Read the site's JavaScript to see what it does with them.
- Follow the value from input to output.
- Find the dangerous places it reaches.
- Note every decoding step along the way.
- Test with harmless payloads first.
- See what the filter blocks.
- Try representations the filter might miss.
- Prove the code runs as the site.
- Work out what it can really do.
- Cut anything you cannot prove.
- Submit the smallest working example.
This workflow is much more reliable than simply throwing hundreds of XSS payloads at parameters.
15. What I would test first on similar targets
If you encounter a parameter resembling:
returnredirectnexturltargetcallback
then investigate these areas first.
Client-side sinks.
location =window.open(...)iframe.src =script.src =element.href =element.setAttribute(...)element.innerHTML =
These are the places where a value becomes an action. If your input reaches one of them, you have a candidate.
Transformations.
decodeURIComponent()decodeURI()atob()JSON.parse()
These are the places where the value changes shape. A filter that checks the input before a transformation may be checking the wrong thing.
URI schemes.
Conceptually test whether the application accepts dangerous protocols such as:
javascript:data:
javascript: runs code. data: embeds content directly in the address, which can also be abused. Check whether the browser, framework, or WAF normalises unusual representations of these.
Context.
Determine whether the final sink is:
HTMLattributeJavaScriptCSSURLDOM API
The correct payload strategy depends heavily on the context. A value dropped into HTML is read differently from one dropped into an attribute, a script, a style, or a URL.
16. Why iframe.src deserves attention
Developers sometimes treat iframe URLs as inherently safe because they are "just URLs". That assumption is dangerous. A URL-valued DOM property is still interpreted by a browser parser. Therefore this:
iframe.src = userInput
should never automatically be considered safe. The browser does not just fetch a page; it reads the scheme and decides what to do. If the scheme is javascript:, it runs code.
A safer design validates the URL scheme and destination explicitly. For example, an application expecting HTTPS URLs should enforce an allowlist such as:
https:
rather than accepting arbitrary URI schemes. An allowlist is a list of things that are permitted; anything not on the list is refused.
17. Recommended fix
The primary fix is to avoid assigning attacker-controlled values directly to a URL-valued DOM sink. Instead:
- Validate the protocol. Only permit expected schemes, for example
https:. - Prefer an allowlist. If the application expects a specific set of domains, validate both
schemeandhostname. The scheme is thehttps:part; the hostname is the site name. - Reject dangerous schemes after decoding. Validation must happen after all relevant decoding steps. Otherwise this pattern still bypasses the protection:
encoded input ↓validation ↓decode ↓dangerous URI
Read it as: the filter checks the encoded text, then the application decodes it into something dangerous, and the browser runs it. The check happened too early.
- Avoid unnecessary dynamic iframe URLs. If the functionality does not require arbitrary URLs, don't allow arbitrary URLs.
- Defence in depth. CSP should complement input validation rather than being relied upon as the only defence. Defence in depth means layering several protections so that one failure does not mean total failure.
18. The most important lesson
The most valuable part of this vulnerability wasn't the final payload. It was the process. A parameter that initially looked like a normal redirect value eventually became:
HTTP parameter ↓SSR state ↓client hydration ↓decodeURIComponent() ↓iframe.src ↓browser URL parser ↓same-origin JavaScript
And the security boundary failed because different layers interpreted the input differently. That is exactly the type of chain to look for when hunting modern web applications.
19. Final takeaways for bug hunters
If the entire investigation had to be reduced to a few rules:
- Trace data, don't just fuzz parameters. The interesting bug was found by following the value into the JavaScript bundle. Fuzzing means firing lots of random inputs and watching for crashes or odd behaviour; tracing means reading the code to see where the value goes.
- Learn browser parsing behaviour. WAFs, frameworks, servers, and browsers don't necessarily normalise data identically.
- Look for decoding functions. A value that looks harmless before decoding may become dangerous afterwards.
- Prove execution with the smallest possible payload. A harmless execution marker is better than immediately attempting credential theft.
- Verify the authentication architecture. Never automatically claim ATO because
document.cookiereturns something. Determine:
Which cookie?HttpOnly?Secure?SameSite?Actually required for authentication?
Secure means the cookie is only sent over HTTPS. SameSite controls whether the cookie is sent with requests from other sites. The question is which cookie actually proves you are logged in, and whether JavaScript can reach it.
- Separate confirmed impact from theoretical impact. This dramatically improves report quality.
- Don't be afraid to downgrade your own finding. Discovering that an assumed ATO chain doesn't work is not failure. It's good security research.
A report that accurately says "This is confirmed XSS, but the primary session cookie is HttpOnly and direct ATO was not demonstrated" is much stronger than an exaggerated report claiming "Critical account takeover" without evidence.
Conclusion
The vulnerability was ultimately a combination of:
Attacker-controlled URL parameter+insufficient URL validation+client-side decoding+unsafe iframe URL assignment+browser URI parsing+WAF/parser differential
The result was a reliable same-origin XSS primitive. The most important lesson wasn't "find a clever XSS payload". It was learning to follow an input through the entire application stack and understand how each layer interprets it. That's the mindset that turns random payload testing into systematic bug hunting.
Disclosure outcome
The vulnerability was accepted after the impact was narrowed to the demonstrated XSS capabilities. The program confirmed the XSS, but noted that the primary authentication cookies were protected and that the demonstrated keylogging scenario required unrealistic interaction. The final severity was therefore reduced from High to Low.
Bounty received: $200.
Glossary
- Allowlist: a list of things that are explicitly permitted; anything not on the list is refused.
- Attribute: a setting on an HTML element, such as its source address or its link target.
- Base64: a way of writing binary data as plain text characters.
- Bounty: a payment made by a company to a researcher who reports a valid security bug.
- Browser parser: the part of the browser that reads text and decides what it means, including what kind of address a URL is.
- CDN (content delivery network): a network of servers that sit in front of a site to speed it up and filter traffic.
- Client-side: happening in the user's browser, rather than on the server.
- Console: the browser's built-in place to type and run JavaScript and see results.
- Content Security Policy (CSP): a set of rules a website sends to the browser saying which scripts are allowed to run.
- Cookie: a small piece of data a website asks the browser to store and send back on every request, often used to remember that you are logged in.
- Cross-site scripting (XSS): a bug where an attacker gets their own JavaScript to run inside someone else's website, in the victim's browser.
- Data flow: the path a value takes through a system, from input to where it is used.
- Defence in depth: layering several protections so that one failure does not mean total failure.
- DevTools: the browser's built-in inspection tools, opened with F12.
- DOM (Document Object Model): the browser's live model of the page, a tree of every element.
- DOM manipulation: changing the page's structure or content from JavaScript.
- Endpoint: a specific address on a website that does one job.
- Fuzzing: firing lots of random or varied inputs at a system and watching for crashes or odd behaviour.
- Hostname: the site name part of a URL, such as
example.com. - HTTP: the protocol browsers and servers use to exchange requests and responses.
HttpOnly: a cookie setting that stops JavaScript from reading that cookie.- Hydration: when a page's JavaScript wakes up and takes over the HTML the server sent, attaching behaviour to it.
- Impact: what an attacker could actually do with a bug.
javascript:scheme: a URL scheme that tells the browser to run the text after the colon as code.- Key handler: code that listens for keystrokes.
localStorage: a browser storage area that persists until cleared.- Origin: the identity of a website (scheme, host and port). Code from one origin cannot read another origin's data.
- Parameter: extra information attached to an address, written as
name=valueafter a?. - Parser differential: when two components read the same input and come to different conclusions about it.
- Payload: the specific input an attacker sends to trigger a bug.
- Phishing: tricking a user into entering information into a fake page.
- Protocol / scheme: the first part of a URL, such as
https:orjavascript:, which tells the browser how to treat the rest. - Reflection: when a site echoes user input back into the page.
SameSite: a cookie setting that controls whether the cookie is sent with requests from other sites.Secure: a cookie setting that means the cookie is only sent over HTTPS.- Server-side rendering (SSR): when the server builds the initial HTML, including a snapshot of data the page will need.
- Session: the period a user is logged in, tracked by a cookie.
- Session theft: stealing the cookie that proves you are logged in, then using it to act as you.
sessionStorage: a browser storage area that lasts until the tab closes.- Single-page application (SPA): a site whose JavaScript takes over after the first page load and updates the page without full reloads.
- Sink: a place in code where data ends up being used in a way that can be dangerous.
- Source: the setting on an iframe that says what address to load.
- URL encoding: writing special characters in a URL in a safe form, such as
%20for a space or%09for a tab. - Whitespace: characters that take up space but show nothing, such as spaces, tabs and newlines.