The Unauthenticated Customer Lookup

Easy

· Backend

Incident

SEV-1

BUG-PANERA

Priority: Critical · reported by security disclosure

Time to fix: 10 min

Failing checks on the shipped build

  • a valid key returns the safe fields

    expected {"status":"ok","customer":{"id":"c1","firstName":"Kai","city":"Pune"}} but got {"status":"ok","customer":{"id":"c1","firstName":"Kai","city":"Pune","address":"12 Elm St","birthday":"1994-02-11","cardLast4":"4417"}}

  • no key means no data

    expected {"status":"unauthorized","customer":null} but got {"status":"ok","customer":{"id":"c1","firstName":"Kai","city":"Pune","address":"12 Elm St","birthday":"1994-02-11","cardLast4":"4417"}}

  • sensitive fields never leave

    card digits must not be returned: expected a truthy value but got false

How to work this incident

  1. Read the report: write down the expected behaviour and the actual one in a sentence each.
  2. Reproduce it: run the visible tests and find the failing check that matches the report.
  3. Read the logs and the failing checks for the first value that is wrong — the earliest wrong value is nearer the cause than the loudest error.
  4. Follow the request through the handler, the validation and the service it calls; find the first step whose output disagrees with the report.
  5. Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.

Inspired by

Panera Bread · 2018

Modelled on the Panera Bread exposure (2018): an ordering API endpoint returned customer names, addresses, birthdays and the last four card digits to anyone who called it — no authentication at all. It stayed open for about eight months after being reported.

lookup.js answers any query.

Fix lookupCustomer so it requires a valid API key and returns only non-sensitive fields.

Code map

exports.lookupCustomer = function (store, customerId, apiKey, validKeys) {
  var customer = store[customerId];
  if (!customer) return { status: "not-found", customer: null };
  return { status: "ok", customer: customer };
};

Sign in to edit the file, run the tests and submit a fix

A free account — no card, no trial clock. You come straight back here.

The Unauthenticated Customer Lookup — JavaScript Bug Hunt

Modelled on the Panera Bread exposure (2018): an ordering API endpoint returned customer names, addresses, birthdays and the last four card digits to anyone…

  • Language: JavaScript
  • Layer: Backend
  • Difficulty: Easy
  • Concepts: Security, Authentication
  • Modelled on: Panera Bread · 2018
  • Visible tests: a valid key returns the safe fields; no key means no data; sensitive fields never leave
  • Reward: 50 XP for a complete fix

Incident

  • Severity: SEV-1 (priority: Critical)
  • Ticket: BUG-PANERA
  • Reported by: security disclosure
  • Time to fix: 10 minutes, the target for an easy incident

Failing checks on the shipped build

  • a valid key returns the safe fields — expected {"status":"ok","customer":{"id":"c1","firstName":"Kai","city":"Pune"}} but got {"status":"ok","customer":{"id":"c1","firstName":"Kai","city":"Pune","address":"12 Elm St","birthday":"1994-02-11","cardLast4":"4417"}}
  • no key means no data — expected {"status":"unauthorized","customer":null} but got {"status":"ok","customer":{"id":"c1","firstName":"Kai","city":"Pune","address":"12 Elm St","birthday":"1994-02-11","cardLast4":"4417"}}
  • sensitive fields never leave — card digits must not be returned: expected a truthy value but got false

How to work this incident

  1. Read the report: write down the expected behaviour and the actual one in a sentence each.
  2. Reproduce it: run the visible tests and find the failing check that matches the report.
  3. Read the logs and the failing checks for the first value that is wrong — the earliest wrong value is nearer the cause than the loudest error.
  4. Follow the request through the handler, the validation and the service it calls; find the first step whose output disagrees with the report.
  5. Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.

Briefing

Modelled on the Panera Bread exposure (2018): an ordering API endpoint returned customer names, addresses, birthdays and the last four card digits to anyone who called it — no authentication at all. It stayed open for about eight months after being reported.

lookup.js answers any query.

Fix lookupCustomer so it requires a valid API key and returns only non-sensitive fields.

Bug report

BUG-PANERA · Priority: Critical · Reported by: security disclosure

lookupCustomer(store, customerId, apiKey, validKeys) must return { status, customer }:

  • "unauthorized" when apiKey is missing or not in validKeys
  • "not-found" when the customer does not exist
  • "ok" with ONLY { id, firstName, city } — never the full address, birthday or card digits

Observed: any caller gets the complete record.

Logs

[api] GET /customer/8812 apiKey=(none) -> full record incl. cardLast4
[api] endpoint open for 8 months

The code as shipped

src/orders/lookup.js (editable)

exports.lookupCustomer = function (store, customerId, apiKey, validKeys) {
  var customer = store[customerId];
  if (!customer) return { status: "not-found", customer: null };
  return { status: "ok", customer: customer };
};

Read-only context: src/orders/MODEL.js.

Open the hunt to start the incident clock, edit the files, run the visible tests and submit against the hidden ones, then write the root cause down. More JavaScript bug hunts.