Blog / A02:2021 Cryptographic Failures
A02:2021 · Cryptographic Failures

X25519 won't save you if you skip the zero check

A peer's key goes into X25519 agreement with no length or low-order check. Some implementations don't reject bad points, and a low-order key can force a predictable secret.

peer supplies apublic keyconverted to acurve key…agreement runslow-order pointforces…ATTACKER INPUTIMPACToutput is predictable
Attack path · peer supplies a public key → converted to a curve key without checks → agreement runs → low-order point forces a predictable secret

A peer's key goes into X25519 agreement with no length or low-order check. Some implementations don't reject bad points, and a low-order key can force a predictable secret.

What goes wrong

X25519 has a reputation for being safe by default, and that reputation is doing damage here. The peer's key is accepted from the caller, wrapped into a curve key, and fed to agreement with no length check and no test for low-order points. The assumption is that the underlying library rejects bad input. Some versions do. Some do not.

Low-order points are the classic problem. Feed one in and the shared secret collapses to a small set of known values, sometimes all zeros. If your code never checks for a zero shared secret, you will derive keys from it and never notice. Validate the key length up front and reject an all-zero result, rather than trusting that every version of every dependency in your build runs the check for you.

The pattern

Vulnerable
function deriveShared(peerKeyBytes):
    // length never checked
    peerKey = toCurveKey(peerKeyBytes)
    // low-order points not rejected here
    secret = x25519(myPrivate, peerKey)
    return secret
Hardened
function deriveShared(peerKeyBytes):
    if (peerKeyBytes.length != 32):
        throw InvalidKey()
    peerKey = toCurveKey(peerKeyBytes)
    secret = x25519(myPrivate, peerKey)
    if (isAllZero(secret)):        // low-order point produced this
        throw InvalidKey()
    return secret
How the pipeline adjudicated itHELD
ABCDEFGH

Grounding and reachability were confirmed. The exploit-path gate would not conclude without the calling code, so the finding was held and an evidence request was raised instead of being reported as fact.

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

Why it matters to you

"The library handles it" is a version-dependent promise. Upgrade, downgrade, or swap the dependency and a check you never wrote can quietly vanish. An all-zero shared secret means an attacker picked your key material for you. Put the length and zero-result checks in your own code so the guarantee does not ride on a transitive dependency's patch level.

Check your own code