The Test Feature That Ships Inside Your ML-DSA Signer

The most persistent ML-DSA incident in Rust services comes from a Cargo feature, not from the lattice math or the NTT. A crate gets a deterministic signing feature for known-answer tests, a dev-dependency turns it on, and the production signer quietly starts deriving every signature from a fixed randomizer. Each diff looks correct on its own, the tests pass, and so does the review. You only find out from a fault-injection report or from an auditor who diffs two signatures over the same message and sees they match byte for byte.

Why review never sees it

Cargo merges features across the dependency graph, and in a virtual workspace that has no explicit resolver setting it falls back to the old resolver, which also merges the features enabled by dev-dependencies into the normal build. Cargo prints a warning about this, but it lands in CI logs that nobody reads after the first week. The pull request that adds the KAT harness touches one member crate's manifest and enables something like a deterministic or test-vectors feature on the core signing crate, and that change is legitimate in its own context. The breakage sits in the root manifest, which nobody edited and so nobody reviewed. Reviewers read diffs, and the bug lives in code that did not change.

What the hedged randomizer was protecting

The NIST post-quantum signature standards define ML-DSA signing as hedged by default: a fresh 32-byte randomizer, rnd, goes into the derivation of the per-signature mask together with the private seed and the message representative, and the deterministic variant simply fixes rnd at zero. That design is what keeps the system standing when one component fails. If the RNG dies, a hedged signer degrades to deterministic security, which is still unforgeable, and you do not get the catastrophic key leak that a repeated ECDSA nonce causes. If instead an attacker can glitch the signing path, the fresh randomness keeps two faulted runs over the same message from lining up, and that is the foundation most differential fault attacks on lattice signatures need. A test feature that pins rnd at compile time removes this second layer of defense and leaves the first one intact, so nothing breaks, no alarm goes off, and verification succeeds every time. The constant-time rejection loop and the zeroized buffers still behave exactly as specified. You are just running a configuration you never chose.

The check you can run before lunch

Build the signer exactly the way your release pipeline does, with the release profile, the production target and the locked lockfile, add verbose output, and grep the rustc invocation for the core ML-DSA crate for its cfg feature flags, because that line records what was actually compiled and does not depend on what any manifest claims. If a deterministic, test, or variable-time feature shows up there, run cargo tree with the features edge kind and invert it on the same crate (the -e features and -i flags) to see which package enabled it, and in our experience (an estimate, not a measurement) the culprit is a dev-dependency or a benchmarking crate in most cases. Then make the check permanent: fail the release job whenever that grep matches, and set the resolver explicitly in the root manifest so the warning stops being something anyone has to notice. Add a runtime guard too, by signing a fixed probe message twice at startup and refusing to serve if the two signatures are identical, which costs two signatures per boot and catches the leak even when someone builds outside CI.

The decision rule: a service that signs must fail closed whenever its compiled feature set includes anything that makes rnd deterministic or swaps in a non-constant-time code path, a service that only verifies can tolerate those features, and you should treat the signing service and the verifying service as separate builds with separate feature allowlists, because the moment they share a workspace profile, the verifier's permissiveness becomes the signer's configuration.

If the RNG fails in production, should the signer fall back to deterministic mode rather than stop?

Only if you have made that choice on purpose and written it down. Deterministic ML-DSA is still secure against forgery, so falling back keeps signing available, but it gives up fault-attack resistance exactly when the hardware may be misbehaving. For signers in physically exposed environments, refuse and page someone. For HSM-backed or isolated signers where glitching is not a realistic threat, a logged fallback is defensible, but it has to be a runtime decision that shows up in your telemetry, never a compile-time feature that nobody can see.

Back to MLDSASafe · Domains

← Back to MLDSASafe
Engineering & Architecture Brief

The Test Feature That Ships Inside Your ML-DSA Signer

The most persistent ML-DSA incident in Rust services comes from a Cargo feature, not from the lattice math or the NTT. A crate gets a deterministic signing feature for known-answer tests, a dev-dependency turns it on, and the production signer quietly starts deriving every signature from a fixed randomizer. Each diff looks correct on its own, the tests pass, and so does the review. You only find out from a fault-injection report or from an auditor who diffs two signatures over the same message and sees they match byte for byte.

Why review never sees it

Cargo merges features across the dependency graph, and in a virtual workspace that has no explicit resolver setting it falls back to the old resolver, which also merges the features enabled by dev-dependencies into the normal build. Cargo prints a warning about this, but it lands in CI logs that nobody reads after the first week. The pull request that adds the KAT harness touches one member crate's manifest and enables something like a deterministic or test-vectors feature on the core signing crate, and that change is legitimate in its own context. The breakage sits in the root manifest, which nobody edited and so nobody reviewed. Reviewers read diffs, and the bug lives in code that did not change.

What the hedged randomizer was protecting

The NIST post-quantum signature standards define ML-DSA signing as hedged by default: a fresh 32-byte randomizer, rnd, goes into the derivation of the per-signature mask together with the private seed and the message representative, and the deterministic variant simply fixes rnd at zero. That design is what keeps the system standing when one component fails. If the RNG dies, a hedged signer degrades to deterministic security, which is still unforgeable, and you do not get the catastrophic key leak that a repeated ECDSA nonce causes. If instead an attacker can glitch the signing path, the fresh randomness keeps two faulted runs over the same message from lining up, and that is the foundation most differential fault attacks on lattice signatures need. A test feature that pins rnd at compile time removes this second layer of defense and leaves the first one intact, so nothing breaks, no alarm goes off, and verification succeeds every time. The constant-time rejection loop and the zeroized buffers still behave exactly as specified. You are just running a configuration you never chose.

The check you can run before lunch

Build the signer exactly the way your release pipeline does, with the release profile, the production target and the locked lockfile, add verbose output, and grep the rustc invocation for the core ML-DSA crate for its cfg feature flags, because that line records what was actually compiled and does not depend on what any manifest claims. If a deterministic, test, or variable-time feature shows up there, run cargo tree with the features edge kind and invert it on the same crate (the -e features and -i flags) to see which package enabled it, and in our experience (an estimate, not a measurement) the culprit is a dev-dependency or a benchmarking crate in most cases. Then make the check permanent: fail the release job whenever that grep matches, and set the resolver explicitly in the root manifest so the warning stops being something anyone has to notice. Add a runtime guard too, by signing a fixed probe message twice at startup and refusing to serve if the two signatures are identical, which costs two signatures per boot and catches the leak even when someone builds outside CI.

The decision rule: a service that signs must fail closed whenever its compiled feature set includes anything that makes rnd deterministic or swaps in a non-constant-time code path, a service that only verifies can tolerate those features, and you should treat the signing service and the verifying service as separate builds with separate feature allowlists, because the moment they share a workspace profile, the verifier's permissiveness becomes the signer's configuration.

Technical FAQ: If the RNG fails in production, should the signer fall back to deterministic mode rather than stop?

Only if you have made that choice on purpose and written it down. Deterministic ML-DSA is still secure against forgery, so falling back keeps signing available, but it gives up fault-attack resistance exactly when the hardware may be misbehaving. For signers in physically exposed environments, refuse and page someone. For HSM-backed or isolated signers where glitching is not a realistic threat, a logged fallback is defensible, but it has to be a runtime decision that shows up in your telemetry, never a compile-time feature that nobody can see.

Related Architecture Specifications (PQCECOSYSTEM): mlkemcompliant.com · mlkemsecurity.com · pqccustody.com

More Technical Articles on mldsasafe.com

Benchmarking Bootloader Verification Delays: ML-DSA vs SLH-DSA vs Classical RSA-3072 →Remote Attestation for Sovereign Cloud Hyperscalers Using Post-Quantum TPM Quotes →The One-Line Cargo Change That Quietly Turns Hedged ML-DSA Signing Deterministic →The ML-DSA fallback that keeps the dashboard green →ML-DSA Reference Architecture: Aligning Memory-Safe Implementations with FIPS 204, LAMPS X.509 Profiles and ACVP Validation →