← GraphQL lesson
Server-SideGraphQLAdvanced35 min+100 XP

GraphQL Directory

The Directory API exposes a user query and GraphQL introspection. Retrieve the administrator's flag field.

“One endpoint. Many doors. The schema told the attacker which ones were unlocked.”

CWE-639OWASP API Security API1:2023OWASP ASVS 4.1.3
The story
GraphQL exposes a typed graph. The client chooses the shape of the response, so the server must authorize every node and field, not just the entry point.

Introspection reveals types and fields. A resolver accepts an ID and returns data without checking ownership. The attacker queries another user's object and requests an admin-only field.

Your objective
  • Run an introspection query
  • Query a user other than your own
  • Request the admin-only flag field and capture it
Boundary under test

Query field to resolver policy

Field guide · request anatomy

Where to look before you type a payload

01Parse

The server parses a query document with fields, aliases, fragments and variables.

02Validate

The schema validates shape, but validation is not authorization.

03Resolve

Each field calls a resolver with a parent object and context.

04Authorize

Every resolver must check whether the subject may read this field on this object.

Progressive hints

Open one hint at a time. The first two build the model; the last two point at the boundary.

Hint 1

Run an introspection query.

Hint 2

Query `user(id: 1)` and then `user(id: 2)`.

Hint 3

Introspection is enabled. Query user(id: 2) and request the flag field.

Hint 4 · near the answer

Query `user(id: 2) { flag }` and capture the flag.

Guided workbench

Observe → Hypothesize → Test → Prove → Explain

This is the same loop a reviewer expects in a report. Your draft stays in this browser; nothing is submitted until you choose to export it.

0/15steps complete
Observe0/3
Hypothesize0/3
Test0/3
Prove0/3
Explain0/3

Evidence log

Write for a reviewer who was not in the room. Every claim needs a request, response or state change behind it.

Preview the evidence report
# Lab evidence report — GraphQL Directory

- Family: GraphQL
- Lab ID: web-graphql-directory
- Date: 2026-12-05

## Workflow

### Observe

- [ ] Open "GraphQL Directory" and record /graphql, the HTTP method and the role you are given.
- [ ] List every parameter, header, cookie and object identifier the normal flow exposes.
- [ ] Save a baseline response: status, body shape, timing and the fields that change by user.

### Hypothesize

- [ ] Name the server decision that protects /graphql, and the evidence it should use.
- [ ] Use the clue as a constraint, not an answer: Introspection is enabled. Query user(id: 2) and request the flag field.
- [ ] Predict the exact status, body or state change that would prove the decision is missing.

### Test

- [ ] Start from the baseline and change one value: the user(id: 2) selection.
- [ ] Keep the request replayable; vary encoding, method or identifier location only after the first result.
- [ ] Capture the full request and response for the winning attempt, including the flag.

### Prove

- [ ] Capture the flag and name the exact foreign object, role or state change it proves.
- [ ] Repeat from a clean session and confirm the result is not cached or stale.
- [ ] State impact precisely: what data or action did you actually obtain?

### Explain

- [ ] State the root cause without naming the payload: which decision failed?
- [ ] Name the control that prevents recurrence and the layer where it belongs.
- [ ] Write one regression test that fails before the fix and passes after it.

## Evidence

### Target and baseline

_Not recorded._

### Hypothesis

_Not recorded._

### Winning request

_Not recorded._

### Proof

_Not recorded._

### Root cause

_Not recorded._

### Control and regression test

_Not recorded._

## Analyst conclusion

The proof demonstrates the missing control above. The regression test should fail against the vulnerable behavior and pass after remediation.
Solution and debrief
Locked until you capture the flag.

The full request, the reasoning and the debrief unlock after a successful capture. That is deliberate: struggle first, then consolidate.

What a reviewer will ask

False positives to rule out

  • Introspection is enabled: this is a hardening issue, not automatically a data breach; test field-level authorization next.
  • A query returns an error for another user's ID: test nested fields, aliases and mutations before concluding the schema is safe.
  • A field is hidden from the docs: the schema may still expose it, and field names can be guessed.

Regression tests to name

  • Cross-tenant object: The resolver returns not found or forbidden
  • Nested field: The child resolver enforces its own policy
  • Mutation input: The schema rejects or ignores privileged fields
The defender's move
  • Enforce field-level and object-level authorization in resolvers.
  • Disable introspection in production and limit query depth/cost.
  • Use persisted queries and rate limits.
See the secure-code pattern and all 4 regression tests →
الخلاصة

GraphQL لا تلغي الحاجة لفحص الصلاحيات لكل حقل.