The Wrong Audience

Medium

· Backend

Incident

SEV-1

BUG-AUD

Priority: Critical · reported by security review

Time to fix: 20 min

Failing checks on the shipped build

  • the wrong audience is rejected

    cross-service token must fail: expected a truthy value but got false

  • expired tokens are rejected

    expected a truthy value but got false

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

OAuth deployments

Inspired by the cross-service token confusion behind several real IdP advisories: a token minted for the analytics API is happily accepted by the payments API, because nobody checks the aud claim. Same issuer, wrong audience, full access.

claims.js validates a decoded token's claims.

Code map

// Validates decoded token claims.
exports.validateClaims = function (claims, expected, nowSeconds) {
  if (claims.iss !== expected.issuer) return false;
  return true;
};

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.

The Wrong Audience — JavaScript Bug Hunt

Inspired by the cross-service token confusion behind several real IdP advisories: a token minted for the analytics API is happily accepted by the payments…

  • Language: JavaScript
  • Layer: Backend
  • Difficulty: Medium
  • Concepts: Security, JWT
  • Modelled on: OAuth deployments
  • Visible tests: a fully matching token passes; the wrong audience is rejected; expired tokens are rejected
  • Reward: 50 XP for a complete fix

Incident

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

Failing checks on the shipped build

  • the wrong audience is rejected — cross-service token must fail: expected a truthy value but got false
  • expired tokens are rejected — expected a truthy value but got false

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

Inspired by the cross-service token confusion behind several real IdP advisories: a token minted for the analytics API is happily accepted by the payments API, because nobody checks the aud claim. Same issuer, wrong audience, full access.

claims.js validates a decoded token's claims.

Bug report

BUG-AUD · Priority: Critical · Reported by: security review

validateClaims(claims, expected, nowSeconds):

  • claims.iss must equal expected.issuer
  • claims.aud must equal expected.audience <- the missing check
  • claims.exp must be strictly in the future

Observed: any token from our issuer opens every service.

Logs

[payments] accepted token aud="analytics-api" (we are payments-api)

The code as shipped

src/auth/claims.js (editable)

// Validates decoded token claims.
exports.validateClaims = function (claims, expected, nowSeconds) {
  if (claims.iss !== expected.issuer) return false;
  return true;
};

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.