Blog / A07:2021 Identification and Authentication Failures
A07:2021 · Identification and Authentication Failures

Two Face Scans, One Set of Globals

Your liveness pipeline stashes landmarks in module-level variables. Two scans overlap and one person's face data lands in the other's accept decision.

scan writeslandmarks…second scanoverwrites themreader picks upmixed dataevidence crossessessionswrong acceptdecisionATTACKER INPUTIMPACTwindow between check and use
Attack path · scan writes landmarks to global → second scan overwrites them → reader picks up mixed data → evidence crosses sessions → wrong accept decision

Your liveness pipeline stashes landmarks in module-level variables. Two scans overlap and one person's face data lands in the other's accept decision.

What goes wrong

The detection code keeps its working data, the detected landmarks and the cropped regions it derives from them, in module-global variables. That is fine when exactly one scan runs at a time. The moment two run concurrently, and async processing makes that easy, they write to the same slots. One scan's landmarks overwrite another's between the write and the read.

By the time the acceptance logic runs, it is reading a single shared value that may belong to a different scan than the faces it is judging. Liveness evidence from one session ends up attached to another. The decision comes out confident and wrong.

This is a time-of-check to time-of-use gap dressed up as convenience. Nothing is corrupt and no memory is unsafe. The state is simply shared where it should have been per-request. Under real traffic, concurrency is the norm, and a biometric check that mixes sessions is one you cannot trust.

The pattern

Vulnerable
let facePoints          // module-global
let cropResults

async function process(image) {
  facePoints = detectLandmarks(image)      // races other scans
  cropResults = cropFaces(image, facePoints)
  return decide(cropResults, facePoints)   // may read another scan
}
Hardened
async function process(image) {
  const facePoints = detectLandmarks(image)   // per-call, local
  const cropResults = cropFaces(image, facePoints)
  return decide(cropResults, facePoints)      // no shared state
}
How the pipeline adjudicated itPROVEN
ABCDEFGH

Every gate held. The exploit path was reproduced against a negative control, the impact was calibrated, and the finding was signed report-ready.

Ed25519 · per-tenant signing key · gate ledger A–H · verify offline against the published payload hash

Why it matters to you

Cross-session contamination in an authentication check is about as bad as it gets. A false accept lets the wrong person in, and a scan that borrows someone else's liveness evidence is the bug that never reproduces on a developer's single-threaded laptop and then shows up the day you get traffic. If your accept or reject decision reads anything from module scope, treat it as a live defect, not a style nit.

Check your own code