Skip to content
Cache bugs Write-up Advanced

Caching the Un-cacheables - Abusing URL Parser Confusions (Web Cache Poisoning Technique)

The author poisoned the cache of thousands of Glassdoor pages with reflected and stored XSS.

Harel Follow

Published on nokline.github.io

Bounty$1,700 View original

Imagine you just picked up a new attractive bug bounty program your friend recommended, and you get excited to try it out because of all the good stories you’ve heard, but after a few days of intensive recon and research, you are left empty handed and end the day with no findings. The next day you start to doubt…

Harel (@h4r3l), on nokline.github.io

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. 7 min read.

Context

Glassdoor runs a large public site under https://www.glassdoor.com, with job search pages under /Job/ and award pages under /Award/. Two behaviours matter here. First, every page under the /Job/ path reflects URL parameters inside a JavaScript string in a <script> tag, and the parameter name is reflected as well as the value. Second, the site sits behind a CDN that caches responses, and the researcher found that the cache rule covers everything under /Award/*.

The write-up chains three separate weaknesses: an unsanitised reflection in /Job/, a cookie value (optimizelyEndUserId) reflected next to that injection point, and a disagreement between the CDN's URL parser and the backend's URL parser about dot segments (/../). The result is reflected XSS through web cache poisoning, and later a stored XSS using a survey endpoint under /mz-survey/.

From the original on nokline.github.io

Setup

The researcher intercepted a request and sent it to Burp Repeater for further inspection. No accounts or special roles are described. The relevant preconditions are:

  • A caching frontend (CDN) in front of the application, whose cache rules can be inferred from HIT/MISS headers.
  • A WAF that inspects the whole URL, not individual parameters, and blocks </script followed by most characters.
  • The optimizelyEndUserId cookie being reflected into the page.

Finding it

The starting point was a reflection in a job page such as:

Text
/Job/new-york-ny-compliance-officer-jobs-SRCH_IL.0,11_IC1132348_KO12,42069.htm

Both the parameter name and its value were reflected unsanitised in the response, inside a string in a script tag. The researcher notes that the program has almost 800 submissions, so this was unlikely to be unnoticed, but it was still there. Two ways to turn the reflection into XSS existed:

  1. Escape the string and inject JavaScript. The strings appeared to be escaped with a backslash, and bypassing that is hard.
  2. Close the script tag and inject a generic HTML XSS payload. No user input was sanitised, so this looked more promising.

Sending ?</script> (URL decoded for readability) was immediately blocked by the WAF. The researcher's approach to WAFs is to start from a blocked payload and remove characters one by one until the request passes, rather than pasting generic bypass payloads. Removing the greater-than sign > produced a 200. Any character after </script, such as </scriptaaa, also triggered the WAF, but whitespace such as %20 was allowed, so the script tag would eventually be closed by the next > in the page.

Splitting the payload across parameters did not help: the WAF rule applied to the entire URL. An alphanumeric HTTP parameter pollution attempt, which the researcher had used before against a similar WAF in this same program, did not work here either.

Looking for a chain link rather than a standalone bug, the researcher examined the cookies and noticed that the value of the optimizelyEndUserId cookie was reflected right next to the injection point. Injecting ><svg> into the cookie closed the script tag and injected HTML. The full payload was:

Text
><svg/onload=a=self['aler'%2B't']%3Ba(document.domain)>

This produced an XSS, but a self XSS only: the attacker cannot force a victim to send custom cookies. Escalation required cache poisoning.

Exploitation

Step 1: map the cache rules

The researcher tested caching behaviour by changing extensions and paths and watching the cache headers. A page such as:

Text
https://www.glassdoor.com/Award/new-york-ny-compliance-officer-jobs-SRCH_IL.0,11_IC1132348_KO12,42069.htm

was cached. Changing the extension still returned a 404 page but with MISS/HIT cache headers, which suggested a pattern rather than a hardcoded list of cached files. https://www.glassdoor.com/Award/somerandomfile returned the same 404 with the same cache headers, while https://www.glassdoor.com/randompath/somerandomfile returned a 404 without caching. The rule was therefore /Award/*: everything under /Award is cached.

Step 2: confirm the XSS surface on /Job/*

Every page under the /Job path was vulnerable to the self XSS, including pages that were supposed to be 404s but returned 200. So the two ingredients were:

  1. The CDN caches /Award/*.
  2. A self XSS exists on /Job/*.

Step 3: test whether the parsers agree on dot segments

The key question was whether the wildcard patterns accept special URL syntax such as /../, or whether the URL is normalised before the pattern is matched, and whether the backend does the same normalisation. Two probes were sent:

Text
/Award/../this_should_not_cache
/Job/../this_should_give_a_404

The results conflicted. The /Award/../ request was not cached, meaning the frontend normalises the dot segment before matching the cache rule. The /Job/../ request returned 200, meaning the backend does not normalise the dot segment. The two parsers disagree, which is a deviation from RFC 3986 section 5.2.4.

Step 4: poison the cache

With that disagreement, a request to a /Job/ path containing /../Award/... is interpreted differently by each side. The backend sees a /Job/ page and returns the response containing the injected XSS; the frontend normalises the path and caches the response under the /Award/ URL. The researcher's example cache key was:

Text
/Award/RANDOMPATHTATDOESNOTEXIST?cachebuster=046&attack=VULN%3C/script%20

A victim visiting https://glassdoor.com/Award/RANDOMPATHTATDOESNOTEXIST?cachebuster=046&attack=VULN%3C/script%20 then receives the stored response with the XSS from the CDN.

Step 5: stored XSS via the survey endpoint

Still looking for a stored XSS, the researcher returned to an earlier report of a reflected XSS in http://glassdoor.com/mz-survey/start_input.htm via alphanumeric ordered parameter pollution, which was still in triage at the time. That endpoint was also vulnerable to a full header XSS, but it did not behave like /Job/*, where every page under the path is vulnerable. Testing the other endpoints from that earlier report led to:

Text
https://glassdoor.com/mz-survey/interview/collectQuestions_input.htm/

This endpoint was vulnerable to header XSS and behaved like /Job/*. The payload was split across two headers and a cookie to bypass the WAF, because the whole payload could not fit into one cookie or header. The X-Forwarded-For header is reflected after the cookie, so the payload continues there. The WAF was stricter for X-Forwarded-For: no special characters at all were allowed. A second header confusion helped: the WAF blocked only the first X-Forwarded-For header, while the web server interpreted and reflected both, so a valid value in the first header and the rest of the payload in the second passed the WAF.

Sending the request to:

Text
https://www.glassdoor.com/mz-survey/interview/collectQuestions_input.htm/../../../Award/blah

with the XSS in the headers and cookies results in a stored XSS under https://www.glassdoor.com/Award/blah. No URL parameter is needed for this variant.

Stored XSS PoC

From the original on nokline.github.io

Root cause

The chain rests on three issues:

  • Unsanitised reflection. Parameter names and values, and the optimizelyEndUserId cookie, are reflected into a script context without sanitisation. The WAF blocks </script followed by most characters but allows whitespace, so the tag can still be closed by a later > in the page.
  • Parser disagreement on dot segments. The caching frontend normalises /../ before matching its cache rule, while the backend does not normalise it. The same URL therefore means different things to the two components, which is what lets a /Job/ response be cached under an /Award/ key.
  • Overly broad cache rule. Caching everything under /Award/*, including 404 pages, is a very relaxed rule with potential to be chained.

Impact

An attacker could poison the cache for pages under /Award/ and serve reflected XSS to any visitor of the poisoned URL, and, via the survey endpoint, achieve stored XSS under https://www.glassdoor.com/Award/blah. The researcher also lists the general uses of web cache poisoning: stored XSS, escalation of an unexploitable XSS to reflected XSS, and DoS. The self XSS alone is not exploitable against a victim because cookies cannot be forced; the cache poisoning step is what makes it reachable.

Fix

Variants to test

  • Dot-segment disagreement. Send /cached-path/../uncached-path and /uncached-path/../cached-path and compare cache headers with the response body. A positive result is a cached response whose body comes from the other path.
  • Wildcard cache rules. Request random files under a cached prefix and under an unrelated prefix, and compare HIT/MISS headers on 404 responses. A positive result is caching of arbitrary non-existent paths under the prefix.
  • Cookie reflection next to a reflection point. Inject ><svg> into cookies reflected near a script string. A positive result is HTML injection without a WAF block.
  • Duplicate headers. Send two X-Forwarded-For headers, the first valid and the second carrying a payload. A positive result is the second value being reflected while the WAF only inspects the first.
  • Whitespace after a blocked tag. Where </script> is blocked, try </script%20 and rely on a later > to close the tag. A positive result is a 200 with the tag closed in the response.

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. 14 min read.

What happened, in plain words

Glassdoor is a website where people look for jobs and read about companies. Two kinds of pages matter in this story: job search pages that live under a path called /Job/, and award pages that live under a path called /Award/. A path is just the part of a web address after the site name, like the folders on your computer.

The researcher found a way to make Glassdoor's own servers store a malicious piece of JavaScript (a small program that runs in a visitor's browser) and then hand it out to other people who visit a normal-looking Glassdoor page. That is called web cache poisoning. The JavaScript could then run in the visitor's browser as if Glassdoor had written it, which is called cross-site scripting, or XSS.

The trick relied on three separate weaknesses that, on their own, were not very useful:

  1. A job page echoed back whatever text you put in the address bar, without cleaning it, inside a piece of JavaScript on the page.
  2. A cookie (a small piece of data the browser stores for a site and sends back with every request) called optimizelyEndUserId was also echoed back on the page, right next to that spot.
  3. The system that stores copies of pages (the cache) and the system that actually builds the pages disagreed about how to read a special piece of a web address, /../.

By combining them, the researcher could make the cache store a poisoned copy of a page under an /Award/ address, and then anyone visiting that address would run the attacker's JavaScript. Later, using a survey page under /mz-survey/, the same idea produced a stored XSS, meaning the malicious content was saved on Glassdoor's side rather than only in one person's browser.

From the original on nokline.github.io

The pieces you need to know first

Before walking through the steps, here are the ideas the report uses, explained from scratch.

  • URL and path. A URL is a web address, like https://www.glassdoor.com/Job/. The part after the site name is the path. Think of the site as a building and the path as the corridor and room number.
  • Query parameters. After a ? in a URL you can add name=value pairs, like ?xss=hello. These are extra instructions sent to the server. The server often copies them back into the page.
  • Reflection. When a server copies something you sent (a parameter, a cookie, a header) straight back into the page it returns, that is a reflection. If it does not clean the text first, you can sometimes make the page do things it was not meant to do.
  • Removing or encoding characters like < and > is the usual approach.
  • XSS (cross-site scripting). A bug where an attacker gets their own JavaScript to run inside someone else's website in a victim's browser. The browser trusts the site, so the script can do things the site could do.
  • Self XSS. An XSS that only works if the victim themselves types the payload or sets a special cookie. It is much less serious because you cannot make a stranger do that.
  • Stored XSS. An XSS where the malicious content is saved on the server and served to everyone who visits a certain page. Much more serious.
  • Cookie. A small label the website sticks on your browser. Your browser shows it back to the site on every request, so the site can remember who you are or what settings you chose.
  • HTTP header. Extra information sent alongside a request or response, separate from the address and the body. Examples include Cookie and X-Forwarded-For.
  • WAF (web application firewall). A filter that sits in front of a website and blocks requests that look malicious, for example requests containing </script>.
  • CDN (content delivery network) and cache. A CDN is a network of servers placed around the world that keep copies of pages so they can be served quickly. Keeping a copy is called caching. When the CDN has a fresh copy it answers with HIT; when it has to ask the real server it answers with MISS.
  • Web cache poisoning. Tricking the cache into storing a malicious response under a normal-looking address, so that other visitors get the malicious copy.
  • Dot segment (/../). In a path, .. means "go up one folder". /Award/../Job/ and /Job/ should mean the same thing once the address is tidied up. Tidying is called normalisation.
  • RFC 3986. The official document that describes how URLs should be written and read. Section 5.2.4 describes how to remove dot segments.
  • DoS (denial of service). Making a service unavailable, for example by filling its cache with junk.

The starting point: a reflection in a job page

The researcher was looking at a job page with this path:

Text
/Job/new-york-ny-compliance-officer-jobs-SRCH_IL.0,11_IC1132348_KO12,42069.htm

This is a normal Glassdoor job listing page. The researcher noticed that both the name and the value of any parameter added to this URL were copied into the response without cleaning, inside a string in a <script> tag. A <script> tag is the part of an HTML page that holds JavaScript. A string is just text inside quotes.

Why does that matter? Because if you can put text inside a script tag, you may be able to break out of the string and run your own JavaScript. The researcher noted that the Glassdoor program already had almost 800 submissions, so this was unlikely to be something nobody had spotted, yet it was still there.

There were two ways to turn the reflection into XSS:

  1. Escape the string and inject JavaScript. The strings appeared to be escaped with a backslash, and bypassing that is hard.
  2. Close the script tag and inject a generic HTML XSS payload. No user input was sanitised, so this looked more promising.

Option 2 means sending </script> so the browser thinks the script has ended, then adding your own HTML that runs code. The researcher tried ?</script> (URL decoded here for readability) and the request was immediately blocked by the WAF.

How the researcher approached the WAF

The researcher's method is worth copying: start from a blocked payload and remove characters one by one until the request passes. Pasting generic bypass payloads without understanding why the WAF blocks you is usually a waste of time. Removing the greater-than sign > produced a 200 response. Any character after </script, such as </scriptaaa, also triggered the WAF, but whitespace such as %20 (a URL-encoded space) was allowed. That meant the script tag would eventually be closed by the next > that appears later in the page.

Splitting the payload across parameters did not help: the WAF rule applied to the entire URL, not to individual parameters. An alphanumeric HTTP parameter pollution attempt, which the researcher had used before against a similar WAF in this same program, did not work here either. Parameter pollution means sending the same parameter more than once and relying on the order in which the server reads them.

The cookie reflection

Looking for a chain link rather than a standalone bug, the researcher examined the cookies. The value of the optimizelyEndUserId cookie was reflected right next to the injection point.

Injecting ><svg> into the cookie closed the script tag and injected HTML. The > closes the tag, and <svg> starts an SVG element, which is a way to draw graphics in HTML but can also carry an event handler. The full payload was:

Text
><svg/onload=a=self['aler'%2B't']%3Ba(document.domain)>

Line by line:

  • > closes the script tag that was open on the page.
  • <svg/onload=...> starts an SVG element with an onload attribute. The browser runs whatever is in onload as soon as the element loads.
  • a=self['aler'%2B't'] builds the word alert from two pieces. %2B is a URL-encoded +, so 'aler'+'t' becomes alert. self refers to the current window. The word is stored in a variable called a.
  • %3B is a URL-encoded semicolon, which separates statements.
  • a(document.domain) calls the function stored in a with the current site's domain name, so an alert box pops up showing the domain.

This produced an XSS, but a self XSS only: the attacker cannot force a victim to send custom cookies. Escalation required cache poisoning.

Mapping the cache rules

The researcher tested caching behaviour by changing extensions and paths and watching the cache headers. A page such as:

Text
https://www.glassdoor.com/Award/new-york-ny-compliance-officer-jobs-SRCH_IL.0,11_IC1132348_KO12,42069.htm

was cached. Changing the extension still returned a 404 page (page not found) but with MISS/HIT cache headers, which suggested a pattern rather than a hardcoded list of cached files. https://www.glassdoor.com/Award/somerandomfile returned the same 404 with the same cache headers, while https://www.glassdoor.com/randompath/somerandomfile returned a 404 without caching. The rule was therefore /Award/*: everything under /Award is cached.

Confirming the XSS surface on /Job/*

Every page under the /Job path was vulnerable to the self XSS, including pages that were supposed to be 404s but returned 200. So the two ingredients were:

  1. The CDN caches /Award/*.
  2. A self XSS exists on /Job/*.

Neither is enough alone. The first gives you a place to store something; the second gives you something worth storing. The question was whether the two could be joined.

Testing whether the parsers agree on dot segments

The key question was whether the wildcard patterns accept special URL syntax such as /../, or whether the URL is normalised before the pattern is matched, and whether the backend does the same normalisation. Two probes were sent:

Text
/Award/../this_should_not_cache
/Job/../this_should_give_a_404

Line by line:

  • /Award/../this_should_not_cache starts under /Award, goes up one level with .., and ends at /this_should_not_cache. If the cache normalises the path first, it will not match the /Award/* rule and will not cache.
  • /Job/../this_should_give_a_404 starts under /Job, goes up one level, and ends at /this_should_give_a_404. If the backend normalises the path, that page does not exist and should return 404.

The results conflicted. The /Award/../ request was not cached, meaning the frontend normalises the dot segment before matching the cache rule. The /Job/../ request returned 200, meaning the backend does not normalise the dot segment. The two parsers disagree, which is a deviation from RFC 3986 section 5.2.4.

Think of it like two people reading the same address. One tidies it up first ("go up one floor, then into room 5") and the other reads it literally ("go into room 5, then go up one floor"). They end up in different places.

Poisoning the cache

With that disagreement, a request to a /Job/ path containing /../Award/... is interpreted differently by each side. The backend sees a /Job/ page and returns the response containing the injected XSS; the frontend normalises the path and caches the response under the /Award/ URL. The researcher's example cache key was:

Text
/Award/RANDOMPATHTATDOESNOTEXIST?cachebuster=046&attack=VULN%3C/script%20

Line by line:

  • /Award/RANDOMPATHTATDOESNOTEXIST is the address the cache will store the response under. It does not need to exist on the real site.
  • ?cachebuster=046 is a parameter whose only job is to make the address unique, so the researcher does not overwrite an existing cached page. The number is arbitrary.
  • &attack=VULN%3C/script%20 is the payload parameter. %3C is a URL-encoded <, and %20 is a URL-encoded space. So the value is VULN</script , which is the beginning of the breakout, with the space that the WAF allowed.

A victim visiting https://glassdoor.com/Award/RANDOMPATHTATDOESNOTEXIST?cachebuster=046&attack=VULN%3C/script%20 then receives the stored response with the XSS from the CDN.

Stored XSS via the survey endpoint

Still looking for a stored XSS, the researcher returned to an earlier report of a reflected XSS in http://glassdoor.com/mz-survey/start_input.htm via alphanumeric ordered parameter pollution, which was still in triage at the time. That endpoint was also vulnerable to a full header XSS, but it did not behave like /Job/*, where every page under the path is vulnerable. Testing the other endpoints from that earlier report led to:

Text
https://glassdoor.com/mz-survey/interview/collectQuestions_input.htm/

This endpoint was vulnerable to header XSS and behaved like /Job/*. The payload was split across two headers and a cookie to bypass the WAF, because the whole payload could not fit into one cookie or header. The X-Forwarded-For header is reflected after the cookie, so the payload continues there. X-Forwarded-For is a header that proxies use to tell the server which client the request originally came from.

The WAF was stricter for X-Forwarded-For: no special characters at all were allowed. A second header confusion helped: the WAF blocked only the first X-Forwarded-For header, while the web server interpreted and reflected both, so a valid value in the first header and the rest of the payload in the second passed the WAF.

Sending the request to:

Text
https://www.glassdoor.com/mz-survey/interview/collectQuestions_input.htm/../../../Award/blah

with the XSS in the headers and cookies results in a stored XSS under https://www.glassdoor.com/Award/blah. No URL parameter is needed for this variant.

Line by line:

  • https://www.glassdoor.com/mz-survey/interview/collectQuestions_input.htm/ is the survey endpoint that reflects headers and cookies.
  • ../../../ are three dot segments, each going up one level. They take the path from the survey folder back to the site root.
  • Award/blah then goes into the /Award/ folder, which the cache covers.

So the backend sees a survey page and reflects the malicious headers and cookies into it, while the cache sees an /Award/blah address and stores the response there. Anyone visiting https://www.glassdoor.com/Award/blah gets the stored XSS.

Stored XSS PoC

From the original on nokline.github.io

Why it worked

The chain rests on three issues:

  • Unsanitised reflection. Parameter names and values, and the optimizelyEndUserId cookie, are reflected into a script context without sanitisation. The WAF blocks </script followed by most characters but allows whitespace, so the tag can still be closed by a later > in the page.
  • Parser disagreement on dot segments. The caching frontend normalises /../ before matching its cache rule, while the backend does not normalise it. The same URL therefore means different things to the two components, which is what lets a /Job/ response be cached under an /Award/ key.
  • Overly broad cache rule. Caching everything under /Award/*, including 404 pages, is a very relaxed rule with potential to be chained.

What an attacker could do

An attacker could poison the cache for pages under /Award/ and serve reflected XSS to any visitor of the poisoned URL, and, via the survey endpoint, achieve stored XSS under https://www.glassdoor.com/Award/blah. The researcher also lists the general uses of web cache poisoning: stored XSS, escalation of an unexploitable XSS to reflected XSS, and DoS. The self XSS alone is not exploitable against a victim because cookies cannot be forced; the cache poisoning step is what makes it reachable.

How to fix it

Things to try on your own targets

  • Dot-segment disagreement. Send /cached-path/../uncached-path and /uncached-path/../cached-path and compare cache headers with the response body. A positive result is a cached response whose body comes from the other path.
  • Wildcard cache rules. Request random files under a cached prefix and under an unrelated prefix, and compare HIT/MISS headers on 404 responses. A positive result is caching of arbitrary non-existent paths under the prefix.
  • Cookie reflection next to a reflection point. Inject ><svg> into cookies reflected near a script string. A positive result is HTML injection without a WAF block.
  • Duplicate headers. Send two X-Forwarded-For headers, the first valid and the second carrying a payload. A positive result is the second value being reflected while the WAF only inspects the first.
  • Whitespace after a blocked tag. Where </script> is blocked, try </script%20 and rely on a later > to close the tag. A positive result is a 200 with the tag closed in the response.

Glossary

  • API: a way for one piece of software to talk to another, like a menu of requests a service accepts.
  • Cache: a store of copies of responses kept so they can be served quickly without asking the real server every time.
  • Cache key: the address a cached response is stored under.
  • CDN (content delivery network): a network of servers around the world that keep copies of pages close to visitors.
  • Cookie: a small piece of data a site stores in your browser and your browser sends back with each request.
  • Cross-site scripting (XSS): a bug where an attacker's JavaScript runs inside someone else's website in a victim's browser.
  • Denial of service (DoS): making a service unavailable, for example by filling its cache with junk.
  • Dot segment: the .. in a path, meaning "go up one level".
  • Header: extra information sent with an HTTP request or response, separate from the address and body.
  • HIT / MISS: cache headers saying whether the cache had a copy (HIT) or had to fetch one (MISS).
  • HTTP parameter pollution: sending the same parameter more than once and relying on how the server reads them.
  • Normalisation: tidying up a URL so equivalent forms become identical, for example removing ...
  • Path: the part of a URL after the site name, like folders on a computer.
  • Query parameter: a name=value pair after ? in a URL, sent to the server as extra instructions.
  • Reflection: when a server copies something you sent straight back into the page.
  • RFC 3986: the official document describing how URLs are written and read.
  • Self XSS: an XSS that only works if the victim themselves supplies the payload, for example by setting a cookie.
  • Stored XSS: an XSS where the malicious content is saved on the server and served to everyone who visits a page.
  • SVG: a way to draw graphics in HTML; it can also carry event handlers like onload.
  • URL: a web address.
  • WAF (web application firewall): a filter in front of a website that blocks requests that look malicious.
  • Web cache poisoning: tricking a cache into storing a malicious response under a normal-looking address.
  • X-Forwarded-For: a header proxies use to tell the server which client the request originally came from.

More by Harel

View all

1 more disclosed report, best first.

More from Glassdoor

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Web cache poisoning and deception

The lesson behind this report.

A cache and the origin disagree about a request, so a poisoned response is served to everyone or a private page is stored as public.