> For the complete documentation index, see [llms.txt](https://gitbook.cdxiaodong.life/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.cdxiaodong.life/web-ying-yong-an-quan/html-zhu-ru/meta.md). Agents can also search and read this documentation through its [MCP server](https://gitbook.cdxiaodong.life/~gitbook/mcp).

# meta标签注入

## 概述

[`<meta>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta) 标签表示不能由其他HTML相关元素表示的元数据。一些 `<meta>` 标签是信息性的，例如：

```html
<meta name="name" content="content">
```

然而，其中一些会以某种方式影响页面，例如：

```html
<meta http-equiv="content-security-policy" content="default-src 'none'; base-uri 'self'">
```

{% hint style="info" %}
内容安全策略（Content Security Policy）不 regulating `<meta>` 元素。
{% endhint %}

`<meta http-equiv=...>` 是页面上的一个标签，可以模拟通常为页面头保留的功能子集。`<meta http-equiv=...>` 可以执行的危险功能包括：

* `set-cookie`：
  * `set-cookie` 指令已从标准中移除，在 Firefox 68 和 Chrome 65 中不再支持。
* `refresh`：
  * 重定向到任何常规URL。
  * 重定向到任何 `data:` URL。

## 使用 data: 方案执行任意JavaScript

带有 `content = "0; data: "` URI 的 `<meta>` 标签可用于执行任意JavaScript代码，例如：

```html
<meta name="language" content="0;data:text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==" http-equiv="refresh"/>
```

这仅在Safari上有效。Firefox和Chrome会阻止这个操作：

* Firefox不允许将顶层框架导航到data URL。
* Chrome不允许导航到顶层 `data:` URI。

## 开放重定向

可以使用以下payload将用户重定向到任意页面：

```html
<meta name="language" content="5;http://malicious-website.com" http-equiv="refresh"/>
```

## 参考资料

* [`<meta>` 和 `<iframe>` 标签链接到SSRF](https://medium.com/@know.0nix/hunting-good-bugs-with-only-html-d8fd40d17b38)
