← Prototype Pollution lesson
Advanced / Zero-DayPrototype PollutionAdvanced45 min+100 XP

Tenant Defaults

The Tenant Settings recursively merges untrusted JSON into a preferences object. Pollute the prototype to inherit administrative access.

“The settings merge looked harmless. It changed every object's inheritance.”

CWE-1321OWASP Top 10 A03:2021OWASP ASVS 5.5.1
The story
JavaScript objects inherit from prototypes. If an attacker can write to `__proto__` or `constructor.prototype`, every object that inherits from it may see the new property.

A recursive merge walks untrusted JSON and assigns keys. When the key is `__proto__`, the assignment reaches the prototype instead of a local property. A later check for `isAdmin` reads the inherited value.

Your objective
  • Inspect the merge endpoint
  • Send a __proto__ or constructor.prototype payload
  • Reach the admin console and capture the flag
Boundary under test

Parsed JSON to object merge

Field guide · request anatomy

Where to look before you type a payload

01Parse

The application accepts JSON, query-string syntax or a config object with nested keys.

02Merge

A recursive merge copies keys without blocking __proto__, constructor or prototype.

03Pollute

The merge writes to Object.prototype or a shared object, affecting every object in the process.

04Inherit

A later lookup such as options.isAdmin or config.escape reads the polluted value.

Progressive hints

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

Hint 1

Find the JSON merge or settings endpoint.

Hint 2

Send a `__proto__` key.

Hint 3

The merge accepts __proto__. Send {"__proto__":{"isAdmin":true}}.

Hint 4 · near the answer

Open the admin console 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 — Tenant Defaults

- Family: Prototype Pollution
- Lab ID: web-proto-tenant
- Date: 2026-12-05

## Workflow

### Observe

- [ ] Open "Tenant Defaults" and record /merge, 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 /merge, and the evidence it should use.
- [ ] Use the clue as a constraint, not an answer: The merger walks every key. Try {"__proto__":{"isAdmin":true}} or constructor.prototype.
- [ ] 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 JSON merge key.
- [ ] 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

  • The response does not show isAdmin: pollution may affect a later request or a different code path in the same process.
  • The merge rejects __proto__: test constructor.prototype and nested variants.
  • A JSON parser blocks the key: query-string parsers, YAML and config loaders may still accept it.

Regression tests to name

  • Proto key: The key is rejected or ignored and no shared object changes
  • Constructor path: The merge blocks the path and Object.prototype is unchanged
  • Cross-request: The normal request is unaffected
The defender's move
  • Use null-prototype objects and freeze prototypes.
  • Allowlist keys and reject `__proto__`, `constructor` and `prototype`.
  • Avoid recursive merge on untrusted input.
See the secure-code pattern and all 4 regression tests →
الخلاصة

تلويث prototype يغيّر كل الكائنات، وليس الكائن الذي أرسلته فقط.