How to fix weak cryptography in embedded firmware

Last updated:

Key takeaways

  • They sound similar but call for different fixes, and a single device can carry more than one at once.
  • A changelog entry saying "upgraded cryptography" is not evidence by itself.

Weak cryptography in embedded firmware spans four related but distinct MITRE weaknesses, read 2026-11-02: a broken or deprecated algorithm (CWE-327, think DES, RC4, MD5 or SHA-1 doing a job that needs real confidentiality or integrity); an algorithm that is sound but under-sized for the job (CWE-326, like a key length an attacker can now brute-force); a cryptographic key hard-coded identically into every shipped unit (CWE-321); and key material, tokens or nonces generated from insufficiently random values (CWE-330). CISA calls continued use of deprecated algorithms a named "bad practice" for any product used in critical infrastructure, and firmware is where these weaknesses are hardest to retire quietly — unlike a web server, you can't always just flip a config flag and redeploy.

Why does this keep showing up in shipping firmware?

CISA's Product Security Bad Practices guidance is direct about the risk: "Information technology products used in service of critical infrastructure or NCFs and that use known insecure or deprecated cryptographic algorithms or lack encryption for the transit or storage of sensitive information are dangerous," specifically naming continued use of TLS 1.0/1.1, MD5, SHA-1 and DES as examples still found in the field. In firmware specifically, this is rarely a deliberate current-day choice — a weak algorithm or key length is usually inherited from an SoC vendor's old reference SDK that nobody has revisited since the product's first revision, or it was a genuinely reasonable call on resource-constrained hardware years ago that has since been replaced by a chip capable of running something stronger, without the firmware's crypto choices being updated to match.

How do the four weaknesses actually differ in practice?

They sound similar but call for different fixes, and a single device can carry more than one at once. CWE-327 (broken/risky algorithm) is an algorithm-choice problem — the cipher itself is weak or deprecated, no matter how it's keyed. CWE-326 (inadequate encryption strength) assumes the algorithm is fine but the parameters aren't — a 64-bit key with AES is still AES, but it isn't adequate anymore. CWE-321 (hard-coded key) is a provisioning problem, not an algorithm problem — even a perfectly strong, modern cipher is defeated the moment every unit of a product shares the same embedded key, since extracting one unit's firmware compromises the entire fleet. CWE-330 (insufficient randomness) undermines whichever algorithm and key length were chosen, because a predictable PRNG seed makes supposedly-random session keys, nonces or tokens guessable regardless of how strong the cipher downstream is. Treating all four as "the crypto is bad" obscures that the actual fixes — swap an algorithm, lengthen a key, change provisioning, change entropy sourcing — are different engineering changes.

What does MITRE recommend for broken or undersized algorithms?

For CWE-327, MITRE's architecture-and-design mitigation is to "use strong, up-to-date cryptographic algorithms," picking "a well-vetted algorithm that is currently considered to be strong by experts in the field" rather than designing one in-house — a custom cipher "will likely be exposed to attacks that are well-understood by cryptographers" that its designer never anticipated. MITRE also flags that strength is not a one-time decision: "periodically ensure that the cryptography has not become obsolete," and design the system so one algorithm can be swapped for another in a future update rather than hard-wiring a single cipher choice a field device can never revise. For CWE-326, the matching fix is sizing keys and algorithm parameters to the protection actually required today, not to what was adequate when the product was first designed — the same algorithm with longer keys is often a smaller firmware change than a full cipher migration.

What does MITRE recommend for hard-coded keys and weak randomness?

For CWE-321, MITRE states the fix directly: "prevention schemes mirror that of hard-coded password storage" — provision each unit with its own key at manufacturing or first boot, ideally derived from a hardware root of trust, instead of compiling one fixed key into every firmware image; our secure boot and hardware root of trust guide covers where that unique key material should actually be anchored in silicon. For CWE-330, MITRE is specific about scale and source: "a 256-bit seed is a good starting point for producing a 'random enough' number," a PRNG "not advertised as being cryptographically secure ... should not be used in security-sensitive contexts," and implementations should "re-seed ... from high quality ... sources, such as hardware devices" — a true hardware random number generator where the silicon has one, rather than a software PRNG seeded from something predictable like an uptime counter or boot timestamp.

How do we verify the fix actually worked?

A changelog entry saying "upgraded cryptography" is not evidence by itself. Confirm an algorithm or key-length change by extracting the shipped firmware binary and checking which crypto library calls, constants and key sizes it actually contains, not what the release notes claim. Confirm a hard-coded key is really gone by comparing binary strings or key material across multiple units from different manufacturing batches — if every sampled unit still produces an identical key or device certificate, per-device provisioning isn't actually happening yet regardless of what the design doc says. Confirm randomness quality by sampling generated tokens, nonces or session keys across many boots — including immediately after first flashing, a common point where a PRNG hasn't gathered real entropy yet — rather than trusting that calling a function named "secure_random" makes the output secure.

SoftWSP's device and firmware security work extracts the actual binary and checks what cryptography it really runs — algorithm choice, key length, whether keys are unique per device, and whether randomness sources are hardware-backed — rather than relying on vendor documentation. See device & firmware security services for how that scope covers CWE-327/326/321/330 alongside other CWE Top 25 classes like the ones in our memory corruption and hard-coded credentials guides.

This guide is based on MITRE's CWE-327, CWE-326, CWE-321 and CWE-330 definitions and CISA's Product Security Bad Practices guidance, read directly 2026-11-02.

Sources

  1. MITRE CWE-327: Use of a Broken or Risky Cryptographic Algorithm
  2. MITRE CWE-326: Inadequate Encryption Strength
  3. MITRE CWE-321: Use of Hard-coded Cryptographic Key
  4. MITRE CWE-330: Use of Insufficiently Random Values
  5. CISA: Product Security Bad Practices (insecure/deprecated cryptographic algorithms)

Frequently asked questions

What counts as "weak cryptography" in firmware, exactly?

MITRE catalogues it as several related but distinct weaknesses. CWE-327 (Use of a Broken or Risky Cryptographic Algorithm) covers a product that "uses a broken or risky cryptographic algorithm or protocol" — DES, RC4, MD5 or SHA-1 used where integrity or confidentiality actually matters, or a home-grown cipher instead of a vetted one. CWE-326 (Inadequate Encryption Strength) is narrower: the algorithm choice is "theoretically sound, but is not strong enough for the level of protection required" — for example a key length a modern attacker can brute-force even though the algorithm itself (like AES) is fine. CWE-321 (Use of Hard-coded Cryptographic Key) is a hard-coded key baked into every unit's firmware image. CWE-330 (Use of Insufficiently Random Values) covers predictable session tokens, nonces or key material generated from a weak pseudo-random number generator (PRNG). A single firmware image can carry more than one of these at once — a hard-coded key encrypted with a broken algorithm is a common combination.

Why do deprecated algorithms like DES, MD5, RC4 and SHA-1 keep showing up in firmware?

CISA's Product Security Bad Practices guidance names this directly as a bad practice for products used in critical infrastructure or National Critical Functions: "Information technology products ... that use known insecure or deprecated cryptographic algorithms or lack encryption for the transit or storage of sensitive information are dangerous," specifically calling out continued use of TLS 1.0/1.1, MD5, SHA-1 and DES. In firmware specifically, this usually isn't a conscious choice — it's inherited from an old SoC vendor SDK or reference design that was never revisited, or chosen years ago for a resource-constrained microcontroller that genuinely couldn't run a modern cipher at the time but has since been replaced by hardware that can.

What is MITRE's recommended fix for a broken or weak algorithm?

CWE-327's architecture-and-design mitigation: "use strong, up-to-date cryptographic algorithms," selecting "a well-vetted algorithm that is currently considered to be strong by experts in the field," and explicitly avoiding home-grown cryptography, since a custom algorithm "will likely be exposed to attacks that are well-understood by cryptographers" that its designer never considered. MITRE also recommends designing for replaceability — "periodically ensure that the cryptography has not become obsolete" and architect the system so one algorithm can be swapped for another in a future firmware update, rather than hard-wiring a single cipher choice that can't be revised without a full product redesign. CISA's parallel recommendation: adopt modern algorithms and, looking forward, begin planning for post-quantum cryptography per NIST guidance.

What is the fix for a hard-coded cryptographic key, and for weak randomness?

For CWE-321, MITRE states plainly that "prevention schemes mirror that of hard-coded password storage" — provision each device with a unique key at manufacturing or first boot (ideally derived from a hardware root of trust) instead of compiling one fixed key into every firmware image; see our [secure boot and hardware root of trust guide](/guides/secure-boot-hardware-root-of-trust/) for where that key material should actually live. For CWE-330, MITRE's mitigation is explicit about scale: "a 256-bit seed is a good starting point for producing a 'random enough' number," PRNGs not advertised as cryptographically secure should not be used in a security context at all, and a generator should "re-seed itself as needed from high quality ... sources, such as hardware devices" — i.e. a true hardware random number generator where the silicon has one, rather than a software PRNG seeded from a predictable value like a boot timestamp.

How do we verify a fix actually worked, rather than just changing a config flag?

Confirm the new algorithm and key length by extracting the actual firmware binary and checking what crypto library calls and constants it contains — a changelog claim isn't evidence. Confirm hard-coded keys are gone by diffing binary strings/entropy across multiple units from different manufacturing batches — if every unit still produces an identical key or certificate, provisioning isn't actually per-device yet. Confirm randomness quality by sampling generated tokens/nonces across many boots (including power-cycle immediately after flashing, a common point where a PRNG hasn't gathered enough entropy yet) and running statistical randomness tests rather than trusting the API name. This is the same evidence standard MITRE's CWE entries point to throughout: a named mitigation is only a fix once it's verified against the shipped binary, not the source comment describing it.

In this cluster