repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
chrome-cache-to-xss.mdMarkdown85 lines6.3 KiBsource raw download

title: "Chrome Cache to XSS" section: "Web Pentesting" sectionSlug: "pentesting-web" sourcePath: "src/pentesting-web/xss-cross-site-scripting/chrome-cache-to-xss.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/pentesting-web/xss-cross-site-scripting/chrome-cache-to-xss.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0"#

Chrome Cache to XSS#

This is a browser-local cache abuse technique in Chrome: you first make the victim cache attacker-influenced content in their own browser, and later force a history navigation that restores the bytes from disk cache in a more dangerous context. This is not the same as CDN/server-side cache poisoning; for shared-cache bugs check Cache Poisoning and Cache Deception.

The original SECCON challenge writeup explains the chain in depth.[1]

The technique revolves around the interaction of two cache types:

For history navigations, bfcache wins if available. Therefore, a successful cache-to-XSS chain usually needs to prevent or evict bfcache so Chrome falls back to disk cache.[1]

Key Points#

Disabling / Evicting bfcache#

The classic trick is to keep a live window.opener relationship using window.open(). In Chrome/Chromium this shows up as the related-active-contents / RelatedActiveContentsExist reason, which prevents the page from being restored from bfcache and makes Chrome fall back to disk cache instead.

Recent research also showed a second practical option: evict the old entry from bfcache by navigating through enough additional documents, while leaving the older HTTP response available in disk cache. This is useful when you need the old cached body but still want a fresh execution context after going back.[2]

Reproducing the behavior#

  1. Visit a webpage, e.g. https://example.com.
  2. Execute open("http://spanote.seccon.games:3000/api/token"), which returns a 500 response.
  3. In the newly opened tab, navigate to http://spanote.seccon.games:3000/. This causes the response of http://spanote.seccon.games:3000/api/token to be kept in disk cache.
  4. Trigger history.back() in the popup/tab.
  5. Because bfcache is disabled by the opener relationship, Chrome restores the previous response from disk cache, rendering the cached JSON response in the page.

You can confirm the behavior using:

Hunting checklist#

When testing this technique in the wild, look for the following combination:

  1. A way to make the victim cache attacker-influenced bytes under a stable URL.
  2. A second code path where the same URL is later treated as a document/navigation target.
  3. A reliable way to disable or evict bfcache.
  4. A final rendering/execution gadget (HTML injection, CSP bypass, JSONP, content-type confusion, alternate response modes, etc.).

Good targets are APIs or debug endpoints that can be reached through one flow but later revisited as a top-level navigation or iframe navigation.

Recent exploitation notes (2025+)#

Practical testing tips#

For more details on bfcache and disk cache, see the browser documentation in the references.[3][4][5][6]

References#