> 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/oauth-authentication/oauth-login-bypass-via-implicit-flow.md).

# Обход входа OAuth через неявный поток

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

#### Контекст лабораторной работы

В этой лабораторной работе используется **OAuth** провайдер для обеспечения входа через аккаунт социальной сети. / Из-за недостаточной **проверки в клиентском приложении**, можно войти в другую учетную запись пользователя **не зная его пароля**.

Цель: войти как **carlos** (электронная почта: `carlos@carlos-montoya.net`). / Доступна учетная запись в социальной сети: `wiener:peter`.

#### Наблюдения

* При попытке входа приложение перенаправляет на страницу OAuth:
  * *«Сейчас мы перенаправим вас для входа через социальную сеть…»*

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

* После аутентификации в домене OAuth и принятия разрешений (профиль + электронная почта) приложение затем отправляет запрос на внутреннюю конечную точку, обычно:
* `POST /authenticate`

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

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

* Этот запрос содержит JSON следующего вида:

{% code overflow="wrap" %}

```json
{
"email":"wiener@hotdog.com",
"username":"wiener",
"token":"MkydN3cYAC6wsKXQJEd5tD3kW1nB9MoWqzdfhyL6BtE"
}
```

{% endcode %}

Ключевой момент: приложение **доверяет** the `email` и `username` полям, переданным клиентом, вместо **строго** связывает эти значения с `токен`.

```json
{
"email":"carlos@carlos-montoya.net",
"username":"carlos",
"token":"MkydN3cYAC6wsKXQJEd5tD3kW1nB9MoWqzdfhyL6BtE"
}
```

#### Эксплуатация

1. Обычно входите через OAuth с учетной записью **wiener**.
2. Перехватите запрос, отправленный на `POST /authenticate`.
3. Измените только поля идентификации, сохранив тот же `токен`:

<figure><img src="/files/4a7105e7a7bae2f2b7eaea13c274d054b99a4933" alt=""><figcaption></figcaption></figure>

4. Отправьте измененный запрос.

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

* Сервер отвечает **`302 Found`**, что указывает на создание сессии и на то, что приложение считает пользователя аутентифицированным.
* Затем мы получаем сессию \*\*, авторизованную как Карлос\*\*.

<figure><img src="/files/b8aaf96104913400deffa833dd445cae51cbb1a4" 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/oauth-authentication/oauth-login-bypass-via-implicit-flow.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.
