Posting on Anyone's Timeline

Easy

· Backend

Incident

SEV-1

BUG-WALL

Priority: Critical · reported by external researcher

Time to fix: 10 min

Failing checks on the shipped build

  • a stranger cannot post on someone's wall

    expected {"ok":false,"error":"forbidden"} but got {"ok":true,"error":null}

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

Facebook · 2013

Modelled on Khalil Shreateh's Facebook report of August 2013. The security researcher found he could post to the timeline of any Facebook user, including people who were not his friends. When his report to the bug-bounty programme was dismissed, he demonstrated it by posting on Mark Zuckerberg's own timeline. Facebook then fixed the flaw (and declined to pay a bounty, since the demonstration broke its rules).

This reconstruction's wall.js checks that both accounts exist and then posts. It never asks whether the actor is allowed to write on that wall.

Fix postToWall so it enforces the wall owner's audience setting.

Code map

var graph = require("./graph");

exports.postToWall = function (g, actorId, ownerId, text) {
  var owner = g.users[ownerId];
  if (!owner) return { ok: false, error: "not_found" };
  if (!g.users[actorId]) return { ok: false, error: "unauthenticated" };
  owner.wall.push({ from: actorId, text: text });
  return { ok: true, error: null };
};

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.

Posting on Anyone's Timeline — JavaScript Bug Hunt

Modelled on Khalil Shreateh's Facebook report of August 2013.

  • Language: JavaScript
  • Layer: Backend
  • Difficulty: Easy
  • Concepts: Security, Auth
  • Modelled on: Facebook · 2013
  • Visible tests: the owner posts on their own wall; a stranger cannot post on someone's wall
  • Reward: 50 XP for a complete fix

Incident

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

Failing checks on the shipped build

  • a stranger cannot post on someone's wall — expected {"ok":false,"error":"forbidden"} but got {"ok":true,"error":null}

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 Khalil Shreateh's Facebook report of August 2013. The security researcher found he could post to the timeline of any Facebook user, including people who were not his friends. When his report to the bug-bounty programme was dismissed, he demonstrated it by posting on Mark Zuckerberg's own timeline. Facebook then fixed the flaw (and declined to pay a bounty, since the demonstration broke its rules).

This reconstruction's wall.js checks that both accounts exist and then posts. It never asks whether the actor is allowed to write on that wall.

Fix postToWall so it enforces the wall owner's audience setting.

Bug report

BUG-WALL · Priority: Critical · Reported by: external researcher

postToWall(g, actorId, ownerId, text) returns { ok, error }:

  • unknown owner -> { ok: false, error: "not_found" }
  • unknown actor -> { ok: false, error: "unauthenticated" }
  • the owner may always post on their own wall
  • audience "friends": a friend of the owner (graph.areFriends) may post
  • audience "only_me": nobody but the owner
  • anyone else -> { ok: false, error: "forbidden" } and the wall is unchanged
  • an allowed post appends { from: actorId, text } and returns { ok: true, error: null }

Observed: a stranger's post appeared on the CEO's timeline.

Logs

[wall] khalil -> mark: "..." (not friends) ok=true

The code as shipped

src/social/wall.js (editable)

var graph = require("./graph");

exports.postToWall = function (g, actorId, ownerId, text) {
  var owner = g.users[ownerId];
  if (!owner) return { ok: false, error: "not_found" };
  if (!g.users[actorId]) return { ok: false, error: "unauthenticated" };
  owner.wall.push({ from: actorId, text: text });
  return { ok: true, error: null };
};

Read-only context: src/social/graph.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.