> For the complete documentation index, see [llms.txt](https://hacktricks.xsx.tw/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacktricks.xsx.tw/pentesting-web/xss-cross-site-scripting/chrome-cache-to-xss.md).

# Chrome Cache to XSS

<details>

<summary><strong>从零开始学习AWS黑客技术，成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE（HackTricks AWS红队专家）</strong></a><strong>！</strong></summary>

* 您在**网络安全公司**工作吗？ 想要在HackTricks中看到您的**公司广告**吗？ 或者想要访问**PEASS的最新版本或下载HackTricks的PDF**吗？ 请查看[**订阅计划**](https://github.com/sponsors/carlospolop)！
* 探索[**PEASS家族**](https://opensea.io/collection/the-peass-family)，我们独家的[**NFTs**](https://opensea.io/collection/the-peass-family)收藏品
* 获取[**官方PEASS和HackTricks周边产品**](https://peass.creator-spring.com)
* **加入** [**💬**](https://emojipedia.org/speech-balloon/) [**Discord群**](https://discord.gg/hRep4RUj7f) 或 [**电报群**](https://t.me/peass) 或在**Twitter**上关注我 🐦[**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
* 通过向[**hacktricks仓库**](https://github.com/carlospolop/hacktricks) **和** [**hacktricks-cloud仓库**](https://github.com/carlospolop/hacktricks-cloud)提交PR来分享您的黑客技巧。

</details>

更深入的细节请查看[**此篇文章**](https://blog.arkark.dev/2022/11/18/seccon-en/#web-spanote)。

本文讨论的技术涉及理解两种主要缓存类型的行为和交互：**后退/前进缓存（bfcache）和磁盘缓存**。bfcache存储页面的完整快照，包括JavaScript堆，优先于磁盘缓存用于后退/前进导航，因为它能够存储更全面的快照。相比之下，磁盘缓存存储从网络获取的资源，不包括JavaScript堆，并用于后退/前进导航以减少通信成本。磁盘缓存的一个有趣方面是它包含使用`fetch`获取的资源，这意味着浏览器将从缓存中渲染访问的URL资源。

### 关键要点：

* **bfcache**在后退/前进导航中优先于磁盘缓存。
* 要使用存储在磁盘缓存中的页面而不是bfcache，必须禁用后者。

### 禁用bfcache：

默认情况下，Puppeteer禁用bfcache，符合Chromium文档中列出的条件。禁用bfcache的一种有效方法是通过使用`RelatedActiveContentsExist`，通过使用`window.open()`打开一个保留对`window.opener`引用的页面。

### 复现行为：

1. 访问一个网页，例如`https://example.com`。
2. 执行`open("http://spanote.seccon.games:3000/api/token")`，将导致服务器响应返回500状态码。
3. 在新打开的选项卡中，导航到`http://spanote.seccon.games:3000/`。此操作将将`http://spanote.seccon.games:3000/api/token`的响应缓存为磁盘缓存。
4. 使用`history.back()`进行后退导航。此操作将导致在页面上呈现缓存的JSON响应。

可以通过在Google Chrome的DevTools中确认磁盘缓存是否被使用来验证。

有关bfcache和磁盘缓存的更多详细信息，请参考[web.dev关于bfcache的文章](https://web.dev/i18n/en/bfcache/)和[Chromium关于磁盘缓存的设计文档](https://www.chromium.org/developers/design-documents/network-stack/disk-cache/)。

<details>

<summary><strong>从零开始学习AWS黑客技术，成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE（HackTricks AWS红队专家）</strong></a><strong>！</strong></summary>

* 您在**网络安全公司**工作吗？ 想要在HackTricks中看到您的**公司广告**吗？ 或者想要访问**PEASS的最新版本或下载HackTricks的PDF**吗？ 请查看[**订阅计划**](https://github.com/sponsors/carlospolop)！
* 探索[**PEASS家族**](https://opensea.io/collection/the-peass-family)，我们独家的[**NFTs**](https://opensea.io/collection/the-peass-family)收藏品
* 获取[**官方PEASS和HackTricks周边产品**](https://peass.creator-spring.com)
* **加入** [**💬**](https://emojipedia.org/speech-balloon/) [**Discord群**](https://discord.gg/hRep4RUj7f) 或 [**电报群**](https://t.me/peass) 或在**Twitter**上关注我 🐦[**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
* 通过向[**hacktricks仓库**](https://github.com/carlospolop/hacktricks) **和** [**hacktricks-cloud仓库**](https://github.com/carlospolop/hacktricks-cloud)提交PR来分享您的黑客技巧。

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacktricks.xsx.tw/pentesting-web/xss-cross-site-scripting/chrome-cache-to-xss.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
