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

# Отражённый XSS только с пользовательскими тегами

### Отражённый XSS в HTML-контексте, где заблокированы все теги, кроме пользовательских

Это приложение блокирует все «классические» HTML-теги; разрешены только пользовательские элементы. Цель лабораторной работы — внедрить пользовательский тег, который автоматически выполняет `alert(document.cookie)` (здесь нужно украсть cookie сессии через alert).

Наблюдения и подход (переформулировано)

* Поскольку все стандартные теги фильтруются, техника заключается в том, чтобы определить/вставить пользовательский тег, который браузер примет.
* Пользовательский тег может содержать обработчики событий — но некоторые события срабатывают только если элемент может получить фокус.
* Пользовательские элементы по умолчанию не могут получать фокус; поэтому необходимо принудительно задать фокус, добавив `tabindex=1` чтобы соответствующее событие запускалось при взаимодействии (например, при клике или табуляции).

<figure><img src="/files/26da53f4c4270619b14fc8fda34dddc710850109" alt=""><figcaption></figcaption></figure>

1. Простой тег — не фокусируемый (не выполняет alert):

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

2. Тот же тег, сделанный фокусируемым с помощью `tabindex` — `onfocus` работает:

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

<figure><img src="/files/8408a0e0abc3472240aff330d759d8c5b423d315" alt=""><figcaption></figcaption></figure>

Итоговый proof of concept (эксфильтрация через перенаправление)

* Мы создаём URL, который внедряет пользовательский тег с помощью `onfocus` вызова `alert(document.cookie)` и принудительно задаём фокус, добавляя `tabindex=1`.
* Пример полезной нагрузки для отправки жертве (инъекция, URL-кодированная в `параметре search` ):

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