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
- Read the report: write down the expected behaviour and the actual one in a sentence each.
- Reproduce it: run the visible tests and find the failing check that matches the report.
- 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.
- Follow the request through the handler, the validation and the service it calls; find the first step whose output disagrees with the report.
- 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=trueThe 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.