> 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/business-logic/failed-state-machine-workaround.md).

# Обход неудачного автомата состояний

### Обход аутентификации через некорректный автомат состояний

Эта лабораторная работа основана на неверных предположениях о последовательности шагов в процессе аутентификации. Используя этот плохо спроектированный автомат состояний, можно обойти аутентификацию, получить доступ к административному интерфейсу и удалить пользователя **carlos**.

Предоставленный идентификатор:

* **Пользователь:** wiener
* **Пароль:** peter

**Основное наблюдение**

Поток подключения разбит на несколько последовательных шагов, включая промежуточный этап выбора роли.

Приложение предполагает, что все шаги выполняются по порядку и что каждый запрос был должным образом проверен перед переходом к следующему.

**Этапы выполнения**

1. Подключение с действительными `wiener:peter` учётными данными.
2. После входа приложение предлагает этап **выбора роли**.

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

* Нажмите «Далее», чтобы продолжить.
* В момент GET-запроса к **селектору роли**, перехватите запрос.

<figure><img src="/files/556aec460caaaae817543a4e32e199eec2c96026" alt=""><figcaption></figcaption></figure>

**Не пропускайте запрос**: заблокируйте или удалите его (drop).

* Именно на этом этапе выполняется проверка роли.

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

Продолжайте процесс без этой проверки.

**Результат**

Приложение ошибочно считает, что все шаги были должным образом проверены. / Пользователь напрямую получает доступ к \*\*панели администратора\*\*, не выбрав и не подтвердив легитимную роль.

Оттуда можно удалить пользователя **carlos** и подтвердить выполнение лабораторной работы.

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


---

# 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/business-logic/failed-state-machine-workaround.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.
