Every Post, One Id at a Time

Medium

· Backend

Incident

SEV-1

BUG-PARLER

Priority: Critical · reported by platform security

Time to fix: 20 min

Failing checks on the shipped build

  • an authenticated caller can read a post

    expected 1 but got undefined

  • an anonymous caller is refused

    expected {"status":"unauthorized","post":null} but got {"status":"ok","post":{"id":"p1","body":"hello"}}

  • the budget stops enumeration

    expected {"status":"rate-limited","post":null} but got {"status":"ok","post":{"id":"p1","body":"hello"}}

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

Parler · 2021

Modelled on the Parler scrape (January 2021): post IDs were sequential, the API required no authentication for reads, and there was no rate limit. A small group enumerated the entire site — roughly 70 TB — in a couple of days.

feed.js serves any post id to anyone as fast as they can ask.

Fix fetchPost so unauthenticated callers are refused and each client is rate limited.

Code map

exports.fetchPost = function (store, postId, session, buckets, limit) {
  var post = store[postId];
  if (!post) return { status: "not-found", post: null };
  return { status: "ok", post: post };
};

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.

Every Post, One Id at a Time — JavaScript Bug Hunt

Modelled on the Parler scrape (January 2021): post IDs were sequential, the API required no authentication for reads, and there was no rate limit.

  • Language: JavaScript
  • Layer: Backend
  • Difficulty: Medium
  • Concepts: Security, Rate Limiting
  • Modelled on: Parler · 2021
  • Visible tests: an authenticated caller can read a post; an anonymous caller is refused; the budget stops enumeration
  • Reward: 50 XP for a complete fix

Incident

  • Severity: SEV-1 (priority: Critical)
  • Ticket: BUG-PARLER
  • Reported by: platform security
  • Time to fix: 20 minutes, the target for a medium incident

Failing checks on the shipped build

  • an authenticated caller can read a post — expected 1 but got undefined
  • an anonymous caller is refused — expected {"status":"unauthorized","post":null} but got {"status":"ok","post":{"id":"p1","body":"hello"}}
  • the budget stops enumeration — expected {"status":"rate-limited","post":null} but got {"status":"ok","post":{"id":"p1","body":"hello"}}

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 Parler scrape (January 2021): post IDs were sequential, the API required no authentication for reads, and there was no rate limit. A small group enumerated the entire site — roughly 70 TB — in a couple of days.

feed.js serves any post id to anyone as fast as they can ask.

Fix fetchPost so unauthenticated callers are refused and each client is rate limited.

Bug report

BUG-PARLER · Priority: Critical · Reported by: platform security

fetchPost(store, postId, session, buckets, limit) must return { status, post }:

  • "unauthorized" when session is missing or has no clientId
  • "rate-limited" when this client has already made limit requests
  • "not-found" when the post does not exist (this still consumes a request)
  • "ok" with the post otherwise

buckets maps clientId -> requests made so far.

Observed: no session is required and no request is counted, so the whole archive can be walked by incrementing the id.

Logs

[feed] served post 0000000001..0000998211 to one client in 41 minutes
[feed] no session, no throttle, sequential ids

The code as shipped

src/feed/feed.js (editable)

exports.fetchPost = function (store, postId, session, buckets, limit) {
  var post = store[postId];
  if (!post) return { status: "not-found", post: null };
  return { status: "ok", post: post };
};

Read-only context: src/feed/POLICY.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.