Skip to content
XSS Write-up Intermediate

Bug Hunting with Param Miner: Cache poisoning with XSS, a peculiar case

A hidden header parameter was reflected unsanitised in the main page body, allowing XSS. Because the page was cached, an attacker could poison the cache so that visitors received the malicious script.

Vuk Ivanovic Follow

Published on medium.com

{{media:0}}

Vuk Ivanovic, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context

This is a real-world cache poisoning case that chained into reflected XSS on the main page of a website. The researcher does not name the bug bounty programme or the target, and states that the details of the attack do not make disclosure of the programme necessary. The affected feature is the site's main page, which is served through a cache. The bug is that a hidden header parameter was reflected, unsanitised, into the body of that main page, and the response was cached.

Setup

The tooling was Burp Suite Professional with the Param Miner extension. Param Miner also works in Burp Community Edition, but with a lot of limitations. Param Miner tests for hidden parameters and also tests for cache poisoning; Burp Pro's scanner tests for XSS. The researcher notes that combining them can produce good bounties, but still requires legwork.

Finding it

Param Miner reported a hidden header parameter that was reflecting its value inside the body of the website's main page. The value was not being properly sanitised for XSS. On the initial review, done with Burp Repeater, it turned out not to be a false positive.

Verification in Repeater was a mistake that took time to figure out. When the researcher tried to replicate the result, that is, the main page rendering with XSS, in Firefox, it failed. Checking the source code showed no trace of the parameter and therefore no XSS.

Exploitation

Step 1: Reproduce with curl instead of the browser

The researcher moved from the browser to curl. The attack was a bash script with a curl command, and the response was checked with curl and grep, done manually:

Bash
curl [https://website.com](https://website.com/) | grep “</script>testing”

The first response had nothing to grep. Then one response showed red font highlighting, but the next few responses had nothing, and then another few had it, and then nothing again. The cache was being cleared fairly quickly, but not quickly enough.

Step 2: Understand why browsers did not show it

With Burp Intruder running infinitely, curl responses contained the hidden parameter while Firefox and Chrome still rendered the website without it. Those two things alone were not enough to attack anyone.

Step 3: Try another browser

After spending time baffled by the problem, and trying to figure out how to present it in a report without it being marked N/A or Informative, the researcher remembered not having tried all the browsers. MS Edge was opened against the affected site and showed nothing, because the cache was cleared too fast or the curl script was too slow. The final curl payload for the bash script was:

Bash
curl -H “User-Agent: tester” -H “hidden-header: </script><h2>TESTERING2333<img src=x onerror=alert(document.domain)>” https://website.com/

This sends a custom User-Agent and a hidden header whose value closes a script context and injects an h2 and an img with an onerror handler that calls alert(document.domain). Upon refreshing a few times in Edge, the payload rendered.

Step 4: Confirm it was not local cache poisoning

The researcher made a few videos and combined a VPS and local environments when testing for cache poisoning and the response, to ensure it was not local cache poisoning.

Step 5: Reporting and reproduction by the vendor

The report was submitted, and the vendor could not reproduce it. The reason, initially, had to do with the vendor trying from a different country than the USA. They contacted colleagues located in the USA, who had no problem reproducing it.

Root cause

The hidden header parameter's value was reflected into the body of the main page without proper sanitisation for XSS, and that response was cached. Why the browsers behaved differently is not explained in the report beyond the observation that Firefox and Chrome rendered the page without the hidden parameter while curl responses contained it. The researcher suggests the geographic difference may have to do with the location of servers.

Impact

An attacker who can get the poisoned response cached could have the injected script run in the browsers of visitors to the main page, in the context of the site's domain, as shown by alert(document.domain). The attack depends on winning the race against the cache being cleared. The researcher notes that the vendor initially could not reproduce it from a different country than the USA.

Fix

The report does not describe a fix. The implied fix is to sanitise the hidden header parameter's value before reflecting it into the page body, and to ensure responses that reflect request headers are not cached.

Variants to test

  1. Run Param Miner against other cached pages and look for hidden header parameters reflected in the body. A positive result is a parameter whose value appears in the response body.
  2. Send the reflected value with an XSS payload and check with curl and grep whether the payload appears in the response. A positive result is the payload appearing intermittently as the cache is cleared and repopulated.
  3. Repeat the check from a different browser and from a different network location, including a VPS, to rule out local cache poisoning and to see whether the poisoned response is served to other clients.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 7 min read.

What happened, in plain words

A security researcher found a bug on a website that could let an attacker run their own code in the browsers of people visiting the site's main page. The bug combined two problems: the site took a value from a hidden request header and put it into the page without cleaning it, and the site stored (cached) that page so other visitors would get the same tainted copy. The researcher used a tool called Param Miner to find the hidden header, then had to work out why the attack only showed up in some browsers and only from some countries. The report does not name the website or the bug bounty programme.

The tools and the setup

To follow this, you need a few basic ideas:

  • HTTP header: when your browser asks a web server for a page, it sends extra lines of text called headers. Some are standard, like User-Agent (which tells the server which browser you use). Others can be custom, like hidden-header in this story. Servers often ignore headers they do not recognise, but sometimes they use them.
  • Parameter: a piece of data sent to the server, either in the URL (like ?name=value) or in a header. A hidden parameter is one the site uses but does not advertise, so you only find it by guessing names and watching for a change in the response.
  • Cache: a storage layer that keeps a copy of a page so it can be served faster next time. If an attacker can make the cache store a malicious copy, every visitor who gets that copy is affected. This is called cache poisoning.
  • Reflected: when a value you send is echoed back in the response. If it is echoed without cleaning, it can become XSS.
  • Sanitise: to clean or encode input so that it cannot break out of its intended place in the page.

The researcher used Burp Suite Professional, a toolkit for testing websites, with an extension called Param Miner. Param Miner works in the free Community Edition too, but with a lot of limitations. Param Miner does two things: it guesses hidden parameters, and it tests for cache poisoning. Burp Pro also has a scanner that tests for XSS. The researcher notes that combining these tools can lead to good bounties, but still requires legwork.

Finding the hidden header

Param Miner reported a hidden header parameter whose value was being reflected inside the body of the website's main page. The value was not properly sanitised for XSS. On the first review, done with Burp Repeater (a tool that lets you send a request and see the response), it turned out not to be a false positive.

But verifying in Repeater was a mistake that took time to figure out. When the researcher tried to replicate the result in Firefox, that is, to see the main page render with XSS, it failed. Checking the page source showed no trace of the parameter, and therefore no XSS.

Exploitation

Step 1: Reproduce with curl instead of the browser

The researcher moved from the browser to curl, a command-line tool that fetches a URL and prints the response. The attack was a bash script with a curl command, and the response was checked with curl and grep (a tool that searches text), done manually:

Bash
curl [https://website.com](https://website.com/) | grep “</script>testing”

This line fetches the main page and searches the response for the text </script>testing. The first response had nothing to grep. Then one response showed red font highlighting, but the next few responses had nothing, and then another few had it, and then nothing again. The cache was being cleared fairly quickly, but not quickly enough.

Step 2: Understand why browsers did not show it

With Burp Intruder (a tool that sends many requests automatically) running infinitely, curl responses contained the hidden parameter while Firefox and Chrome still rendered the website without it. Those two things alone were not enough to attack anyone.

Step 3: Try another browser

After spending time baffled by the problem, and trying to figure out how to present it in a report without it being marked N/A or Informative, the researcher remembered not having tried all the browsers. MS Edge was opened against the affected site and showed nothing, because the cache was cleared too fast or the curl script was too slow. The final curl payload for the bash script was:

Bash
curl -H “User-Agent: tester” -H “hidden-header: </script><h2>TESTERING2333<img src=x onerror=alert(document.domain)>” https://website.com/

This sends a custom User-Agent header with the value tester and a hidden header whose value closes a script context and injects an h2 element and an img element with an onerror handler that calls alert(document.domain). The onerror handler runs if the image fails to load, which it will because src=x is not a real image. alert(document.domain) shows a pop-up with the domain of the page, proving the code runs in the site's context. Upon refreshing a few times in Edge, the payload rendered.

Step 4: Confirm it was not local cache poisoning

The researcher made a few videos and combined a VPS (a virtual private server, a rented computer on the internet) and local environments when testing for cache poisoning and the response, to ensure it was not local cache poisoning (where only the attacker's own browser caches the malicious copy).

Step 5: Reporting and reproduction by the vendor

The report was submitted, and the vendor could not reproduce it. The reason, initially, had to do with the vendor trying from a different country than the USA. They contacted colleagues located in the USA, who had no problem reproducing it.

Root cause

The hidden header parameter's value was reflected into the body of the main page without proper sanitisation for XSS, and that response was cached. Why the browsers behaved differently is not explained in the report beyond the observation that Firefox and Chrome rendered the page without the hidden parameter while curl responses contained it. The researcher suggests the geographic difference may have to do with the location of servers.

Impact

An attacker who can get the poisoned response cached could have the injected script run in the browsers of visitors to the main page, in the context of the site's domain, as shown by alert(document.domain). The attack depends on winning the race against the cache being cleared. The researcher notes that the vendor initially could not reproduce it from a different country than the USA.

Fix

The report does not describe a fix. The implied fix is to sanitise the hidden header parameter's value before reflecting it into the page body, and to ensure responses that reflect request headers are not cached.

Variants to test

  1. Run Param Miner against other cached pages and look for hidden header parameters reflected in the body. A positive result is a parameter whose value appears in the response body.
  2. Send the reflected value with an XSS payload and check with curl and grep whether the payload appears in the response. A positive result is the payload appearing intermittently as the cache is cleared and repopulated.
  3. Repeat the check from a different browser and from a different network location, including a VPS, to rule out local cache poisoning and to see whether the poisoned response is served to other clients.

Glossary

  • HTTP header: extra lines of text sent with a web request or response, carrying information like browser type or cookies.
  • Parameter: a piece of data sent to a server, often in the URL or in a header.
  • Hidden parameter: a parameter the site uses but does not advertise, found by guessing names.
  • Cache: a storage layer that keeps copies of responses to serve them faster.
  • Cache poisoning: making a cache store a malicious response so other users receive it.
  • XSS (cross-site scripting): a bug where untrusted input is placed into a page without sanitisation, letting an attacker run code in a victim's browser.
  • Reflected: when input is echoed back in the response.
  • Sanitise: to clean or encode input so it cannot break out of its intended context.
  • Burp Suite Professional: a paid toolkit for testing web applications.
  • Burp Community Edition: the free version of Burp Suite, with fewer features.
  • Param Miner: a Burp extension that finds hidden parameters and tests for cache poisoning.
  • Burp Repeater: a Burp tool to send a single request and inspect the response.
  • Burp Intruder: a Burp tool to send many requests automatically.
  • curl: a command-line tool to fetch URLs and print responses.
  • grep: a command-line tool to search text for a pattern.
  • bash script: a file containing commands for the Unix shell.
  • VPS (virtual private server): a rented computer on the internet, used here to test from a different network location.
  • N/A or Informative: labels some bug bounty programmes use for reports they consider not actionable or not a vulnerability.
  • User-Agent: an HTTP header that identifies the browser or client making the request.
  • onerror: an HTML attribute that runs code if an image fails to load.
  • alert(document.domain): JavaScript that shows a pop-up with the current page's domain, often used to prove XSS.
  • Local cache poisoning: a cache poisoning that only affects the attacker's own browser, not other users.

More by Vuk Ivanovic

View all

13 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.