> 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-with-custom-tags-only.md).

# XSS réfléchi avec uniquement des balises personnalisées

### XSS réfléchi dans un contexte HTML avec tous les tags bloqués sauf les tags personnalisés

Cette application bloque tous les tags HTML « classiques » ; seuls les éléments personnalisés sont autorisés. L'objectif du laboratoire est d'injecter une balise personnalisée qui s'exécute automatiquement `alert(document.cookie)` (ici, vous voulez voler le cookie de session via l'alerte).

Observations et approche (reformulé)

* Comme toutes les balises standard sont filtrées, la technique consiste à définir/insérer une balise personnalisée que le navigateur acceptera.
* Une balise personnalisée peut contenir des gestionnaires d'événements — mais certains événements ne se déclenchent que si l'élément peut recevoir le focus.
* Les éléments personnalisés ne sont pas focalisables par défaut ; il est donc nécessaire de forcer le focus en ajoutant `tabindex=1` afin que l'événement associé s'exécute lors de l'interaction (par ex. en cliquant ou en tabulant).

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

1. Balise simple — non focalisable (n'exécute pas l'alerte) :

```javascript
<jordan onfocus=alert(0)>HELLO
```

2. Même balise, rendue focalisable avec `tabindex` — `onfocus` fonctionne :

```javascript
<jordan onfocus=alert(0) tabindex=1>HELLO
```

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

Preuve de concept finale (exfiltration via redirection)

* Nous construisons une URL qui injecte la balise personnalisée avec un `onfocus` appelant `alert(document.cookie)` et forçons le focus en `tabindex=1`.
* Exemple de charge utile à envoyer à la victime (injection encodée en URL dans le `paramètre de recherche` paramètre) :

{% code overflow="wrap" %}

```javascript
<script>
location = 'https://0a07009c03dde34d825bba7b0028004d.web-security-academy.net/?search=%3Cjordan%20id=x%20onfocus=alert(document.cookie)%20tabindex=1%3E#x';
</script>
```

{% endcode %}


---

# 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-with-custom-tags-only.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.
