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
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
}async function process(image) {
const facePoints = detectLandmarks(image) // per-call, local
const cropResults = cropFaces(image, facePoints)
return decide(cropResults, facePoints) // no shared state
}Every gate held. The exploit path was reproduced against a negative control, the impact was calibrated, and the finding was signed report-ready.
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
- Find module-level or static variables written during request processing.
- Move per-request working data into locals or a per-call context object.
- Load-test the auth path with concurrent requests and look for mixed results.
- Confirm no acceptance decision reads state that another request can write.