Public by Default — JavaScript Bug Hunt
Modelled on Facebook's June 2018 disclosure: between May 18 and May 27, 2018, a bug affecting about 14 million users set the suggested audience for their…
- Language: JavaScript
- Layer: Frontend
- Difficulty: Easy
- Concepts: Privacy, State, Rendering
- Modelled on: Facebook · 2018
- Visible tests: the feed composer keeps the last audience; featured items keep the last audience too
- Reward: 50 XP for a complete fix
Incident
- Severity: SEV-2 (priority: High (privacy))
- Ticket: BUG-FB-AUDIENCE
- Reported by: user reports
- Time to fix: 10 minutes, the target for an easy incident
Failing checks on the shipped build
- featured items keep the last audience too — context must not change the audience: expected "friends" but got "public"
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 value the screen shows back through the state and the pure helpers that compute it; the view is usually only the messenger.
- 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 Facebook's June 2018 disclosure: between May 18 and May 27, 2018, a bug affecting about 14 million users set the suggested audience for their new posts to Public, whatever they had chosen before. Facebook said it happened while it was building a new way to share featured items on profiles, and it asked affected users to review their posts.
This project is a reconstruction: audience.js picks the audience preselected in the post composer, and the locked picker.js renders it. A code path added for featured items suggests "public" outright, and the fallback for users with no history is "public" too.
Fix suggestAudience so the suggestion is always the user's own last choice, or the most private option.
Bug report
BUG-FB-AUDIENCE · Priority: High (privacy) · Reported by: user reports
suggestAudience(profile, context) returns the audience preselected in the composer. The result is the SAME whatever the context ("feed", "featured", "profile", …):
- profile.lastAudience if it is one of options.AUDIENCES
- otherwise (missing or unrecognised) the most private option, AUDIENCES[0] ("only_me")
"public" is suggested only to someone whose last choice was "public".
Observed: in the featured-items flow a user whose last post was friends-only gets "public" preselected.
Logs
[composer] ctx=featured user=… last=friends suggested=public
[composer] ctx=feed user=… last=(none) suggested=publicThe code as shipped
src/composer/audience.js (editable)
var AUDIENCES = require("./options").AUDIENCES;
// The audience preselected when the composer opens.
exports.suggestAudience = function (profile, context) {
if (context === "featured") return "public";
if (profile.lastAudience) return profile.lastAudience;
return "public";
};
Read-only context: src/composer/options.js, src/composer/picker.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.