Distance to the Decimal

Easy

· Backend

Incident

SEV-2

BUG-TINDER-LOC

Priority: High (privacy) · reported by external researcher

Time to fix: 10 min

Failing checks on the shipped build

  • the distance is whole miles

    6.909 miles rounds to 7: expected 7 but got 6.909409442795153

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

Tinder · 2014

Modelled on the Tinder location-privacy flaw reported by Include Security in 2014. Tinder's API returned the distance to other users with very high precision, so by requesting it from three spoofed positions an attacker could trilaterate someone's location to within about 100 feet. Tinder fixed it after it was reported.

This project is a reconstruction: nearby.js builds the profile card one user sees of another. It returns the raw distance from the locked geo.js — and the other user's coordinates along with it.

Fix toPublicProfile so the card carries a coarse distance and nothing else about location.

Code map

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

exports.toPublicProfile = function (viewer, other) {
  return {
    id: other.id,
    name: other.name,
    distanceMiles: geo.haversineMiles(viewer, other),
    lat: other.lat,
    lon: other.lon
  };
};

exports.listNearby = function (viewer, others) {
  return others.map(function (o) { return exports.toPublicProfile(viewer, o); });
};

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.

Distance to the Decimal — JavaScript Bug Hunt

Modelled on the Tinder location-privacy flaw reported by Include Security in 2014.

  • Language: JavaScript
  • Layer: Backend
  • Difficulty: Easy
  • Concepts: Security, Privacy
  • Modelled on: Tinder · 2014
  • Visible tests: the card names the right person; the distance is whole miles
  • Reward: 50 XP for a complete fix

Incident

  • Severity: SEV-2 (priority: High (privacy))
  • Ticket: BUG-TINDER-LOC
  • Reported by: external researcher
  • Time to fix: 10 minutes, the target for an easy incident

Failing checks on the shipped build

  • the distance is whole miles — 6.909 miles rounds to 7: expected 7 but got 6.909409442795153

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 Tinder location-privacy flaw reported by Include Security in 2014. Tinder's API returned the distance to other users with very high precision, so by requesting it from three spoofed positions an attacker could trilaterate someone's location to within about 100 feet. Tinder fixed it after it was reported.

This project is a reconstruction: nearby.js builds the profile card one user sees of another. It returns the raw distance from the locked geo.js — and the other user's coordinates along with it.

Fix toPublicProfile so the card carries a coarse distance and nothing else about location.

Bug report

BUG-TINDER-LOC · Priority: High (privacy) · Reported by: external researcher

toPublicProfile(viewer, other) — users are { id, name, lat, lon, … }. Return EXACTLY { id, name, distanceMiles } (in that key order):

  • distanceMiles = Math.round(geo.haversineMiles(viewer, other)), and never less than 1 (anything under a mile, including 0, is reported as 1)
  • no coordinates and no other field of other may appear

listNearby(viewer, others) maps toPublicProfile over others, in order.

Observed: the card carries distanceMiles: 6.909… and the user's lat/lon.

Logs

GET /user/recs -> [{"id":"52b4…","distanceMiles":6.909390495,"lat":…,"lon":…}]

The code as shipped

src/nearby/nearby.js (editable)

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

exports.toPublicProfile = function (viewer, other) {
  return {
    id: other.id,
    name: other.name,
    distanceMiles: geo.haversineMiles(viewer, other),
    lat: other.lat,
    lon: other.lon
  };
};

exports.listNearby = function (viewer, others) {
  return others.map(function (o) { return exports.toPublicProfile(viewer, o); });
};

Read-only context: src/nearby/geo.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.