hacktricks/pentesting-web/xss-cross-site-scripting/chrome-cache-to-xss.md

57 lines
4.4 KiB
Markdown
Raw Normal View History

2023-01-12 13:44:25 +00:00
# Chrome Cache to XSS
2024-07-19 14:12:09 +00:00
{% hint style="success" %}
Learn & practice AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
Learn & practice GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
2023-01-12 13:44:25 +00:00
<details>
2024-07-19 14:12:09 +00:00
<summary>Support HackTricks</summary>
2023-01-12 13:44:25 +00:00
2024-07-19 14:12:09 +00:00
* Check the [**subscription plans**](https://github.com/sponsors/carlospolop)!
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2023-01-12 13:44:25 +00:00
</details>
2024-07-19 14:12:09 +00:00
{% endhint %}
2023-01-12 13:44:25 +00:00
2024-02-06 03:10:27 +00:00
More in depth details [**in this writeup**](https://blog.arkark.dev/2022/11/18/seccon-en/#web-spanote).
2023-01-12 13:44:25 +00:00
2024-02-06 03:10:27 +00:00
The technique discussed here involves understanding the behavior and interaction of two primary cache types: the **back/forward cache (bfcache)** and the **disk cache**. The bfcache, which stores a complete snapshot of a page including the JavaScript heap, is prioritized over the disk cache for back/forward navigations due to its ability to store a more comprehensive snapshot. The disk cache, in contrast, stores resources fetched from the web without including the JavaScript heap, and is utilized for back/forward navigations to reduce communication costs. An interesting aspect of the disk cache is its inclusion of resources fetched using `fetch`, meaning accessed URL resources will be rendered by the browser from the cache.
2023-01-12 13:44:25 +00:00
2024-02-06 03:10:27 +00:00
### Key Points:
2023-01-12 13:44:25 +00:00
2024-02-06 03:10:27 +00:00
- The **bfcache** has precedence over the disk cache in back/forward navigations.
- To utilize a page stored in disk cache instead of bfcache, the latter must be disabled.
2023-01-12 13:44:25 +00:00
2024-02-06 03:10:27 +00:00
### Disabling bfcache:
2023-01-12 13:44:25 +00:00
2024-02-06 03:10:27 +00:00
By default, Puppeteer disables bfcache, aligning with conditions listed in Chromium's documentation. One effective method to disable bfcache is through the use of `RelatedActiveContentsExist`, achieved by opening a page with `window.open()` that retains a reference to `window.opener`.
2023-01-12 13:44:25 +00:00
2024-02-06 03:10:27 +00:00
### Reproducing the behavior:
2023-01-12 13:44:25 +00:00
2024-02-06 03:10:27 +00:00
1. Visit a webpage, e.g., `https://example.com`.
2. Execute `open("http://spanote.seccon.games:3000/api/token")`, which results in a server response with a 500 status code.
3. In the newly opened tab, navigate to `http://spanote.seccon.games:3000/`. This action caches the response of `http://spanote.seccon.games:3000/api/token` as a disk cache.
4. Use `history.back()` to navigate back. The action results in the rendering of the cached JSON response on the page.
2023-01-12 13:44:25 +00:00
2024-02-06 03:10:27 +00:00
Verification that the disk cache was utilized can be confirmed through the use of DevTools in Google Chrome.
2023-01-12 14:56:14 +00:00
2024-02-06 03:10:27 +00:00
For further details on bfcache and disk cache, references can be found at [web.dev on bfcache](https://web.dev/i18n/en/bfcache/) and [Chromium's design documents on disk cache](https://www.chromium.org/developers/design-documents/network-stack/disk-cache/), respectively.
2023-01-12 14:56:14 +00:00
2023-01-12 13:44:25 +00:00
2024-07-19 14:12:09 +00:00
{% hint style="success" %}
Learn & practice AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
Learn & practice GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
2023-01-12 13:44:25 +00:00
<details>
2024-07-19 14:12:09 +00:00
<summary>Support HackTricks</summary>
2023-01-12 13:44:25 +00:00
2024-07-19 14:12:09 +00:00
* Check the [**subscription plans**](https://github.com/sponsors/carlospolop)!
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2023-01-12 13:44:25 +00:00
</details>
2024-07-19 14:12:09 +00:00
{% endhint %}