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

The private key was only as safe as the caller's random source

A key-agreement object let its caller supply the randomness used to make a long-term X25519 private key. Predict that source and you recover the key, and every secret it derived.

caller builds thekey-agreement…supplies arandomness sourceobject generatesthe private…predictablesource yields…all derivedshared…ATTACKER INPUTIMPACToutput is predictable
Attack path · caller builds the key-agreement object → supplies a randomness source → object generates the private key from it → predictable source yields a recoverable key → all derived shared secrets exposed

A key-agreement object let its caller supply the randomness used to make a long-term X25519 private key. Predict that source and you recover the key, and every secret it derived.

What goes wrong

This is the weak-nonce mistake again, with worse stakes. The object generates a long-lived X25519 private key, and the entropy behind that key comes from a randomness source the caller supplied. No validation, no internal source, just direct use.

A private key is only private because the number behind it was unpredictable. If the caller hands over a deterministic or reused generator, the private key is derivable by anyone who can reproduce that generator's output. From the private key, every session key and shared secret the object ever negotiated falls out with it. Traffic that anyone recorded becomes readable after the fact.

Long-term keys deserve stricter handling than ephemeral values, because their blast radius is measured in the lifetime of the identity rather than one message. Sourcing their entropy from outside the boundary is the wrong place to be flexible.

The pattern

Vulnerable
class KeyAgreement:
    def __init__(self, rng):
        self.private = x25519_generate(rng)   # entropy from caller
        self.public = x25519_public(self.private)

    def shared_secret(self, peer_pub):
        return x25519(self.private, peer_pub)
Hardened
class KeyAgreement:
    def __init__(self):
        rng = system_secure_random()          # entropy owned here
        self.private = x25519_generate(rng)
        self.public = x25519_public(self.private)

    def shared_secret(self, peer_pub):
        return x25519(self.private, peer_pub)
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

Any identity built on this key is forgeable, and any conversation it protected is decryptable, retroactively, the moment an attacker learns or influences the entropy source. That includes the dull failure mode where someone wires in a fixed seed to make tests reproducible and it escapes into a release.

Check your own code