Audio Before the Call Was Answered

Medium

· Backend

Incident

SEV-1

BUG-FACETIME

Priority: Critical (privacy) · reported by security

Time to fix: 20 min

Failing checks on the shipped build

  • a participant added while ringing does not stream

    no media before the call is answered: expected {"userId":"self","streaming":false} but got {"userId":"self","streaming":true}

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

Apple FaceTime · 2019

Modelled on the Apple Group FaceTime bug (January 2019): adding your own number to a group call put the callee's device into a state where it transmitted audio before the call was answered. Apple disabled Group FaceTime server-side for over a week.

call.js starts the media stream as soon as a participant is added, whatever state the call is in.

Fix addParticipant so media only flows once the call is genuinely answered.

Code map

exports.addParticipant = function (call, userId) {
  var p = { userId: userId, streaming: true };
  call.participants.push(p);
  return p;
};

exports.answerCall = function (call) {
  call.state = "answered";
  for (var i = 0; i < call.participants.length; i++) {
    call.participants[i].streaming = true;
  }
  return call;
};

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.

Audio Before the Call Was Answered — JavaScript Bug Hunt

Modelled on the Apple Group FaceTime bug (January 2019): adding your own number to a group call put the callee's device into a state where it transmitted…

  • Language: JavaScript
  • Layer: Backend
  • Difficulty: Medium
  • Concepts: Security, State Machine
  • Modelled on: Apple FaceTime · 2019
  • Visible tests: a participant added while ringing does not stream; answering starts media for everyone present
  • Reward: 50 XP for a complete fix

Incident

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

Failing checks on the shipped build

  • a participant added while ringing does not stream — no media before the call is answered: expected {"userId":"self","streaming":false} but got {"userId":"self","streaming":true}

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 Apple Group FaceTime bug (January 2019): adding your own number to a group call put the callee's device into a state where it transmitted audio before the call was answered. Apple disabled Group FaceTime server-side for over a week.

call.js starts the media stream as soon as a participant is added, whatever state the call is in.

Fix addParticipant so media only flows once the call is genuinely answered.

Bug report

BUG-FACETIME · Priority: Critical (privacy) · Reported by: security

addParticipant(call, userId) must:

  • add the user to call.participants
  • start streaming that participant's media ONLY when call.state is "answered"
  • while the state is "ringing", the participant is added with streaming false
  • return the resulting participant record

answerCall(call) flips the state to "answered" and starts media for everyone already present.

Observed: adding a participant while the call is still ringing starts their media immediately, so the callee is heard before picking up.

Logs

[call] participant self added while state=ringing streaming=true
[call] callee audio transmitted 11s before answer

The code as shipped

src/calls/call.js (editable)

exports.addParticipant = function (call, userId) {
  var p = { userId: userId, streaming: true };
  call.participants.push(p);
  return p;
};

exports.answerCall = function (call) {
  call.state = "answered";
  for (var i = 0; i < call.participants.length; i++) {
    call.participants[i].streaming = true;
  }
  return call;
};

Read-only context: src/calls/STATES.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.