A face match is only as trustworthy as the reference it compares against. If the caller supplies both sides, the caller decides the result.
What goes wrong
The camera works perfectly. The reference it compares against is the attacker's own face. A biometric match answers one question: does the live capture match the enrolled reference. The security of the whole thing rests on that reference being real, meaning it came from a signed credential the user actually holds. This code skips that part.
The reference images arrive as a parameter and get used as-is. Nothing checks that they came from an authenticated, tamper-evident source, and the payload is pulled out of a data URI without honoring the declared type. So an attacker who can influence that parameter supplies a reference matching their own face, presents that face to the camera, and the comparison returns a clean match. The state machine flips to authenticated. The camera never lied. The reference did.
The pattern
function buildScanner(referenceImages) {
const ref = extractPayload(referenceImages[0]) // trusted blindly
return scanner.onCapture(live => {
if (faceMatch(live, ref)) state = "authenticated"
})
}function buildScanner(credential) {
verifySignature(credential) // reject unsigned or tampered
assertBoundToUser(credential, session.user)
const ref = extractPayload(credential.image)
return scanner.onCapture(live => {
if (faceMatch(live, ref)) state = "authenticated"
})
}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
Biometrics feel strong because a face is hard to fake in front of a camera. That intuition hides the real trust boundary, which is the reference, not the capture. Let the reference in through an unauthenticated channel and you have built an identity check that verifies the attacker against the attacker.
Anywhere you compare a live signal to a stored template, the template has to arrive over a path you trust, signed and bound to the right user, and verified before a single comparison runs. If you cannot prove where the reference came from, the match proves nothing.
Check your own code
- Trace where your biometric reference template comes from and confirm its signature is verified before comparison.
- Reject reference data passed directly by a caller unless it is cryptographically bound to the authenticated user.
- Stop trusting a data URI's declared type; validate the decoded bytes.
- Check that an unverifiable reference blocks authentication instead of defaulting to a compare.