CWE-321: Use of Hard-coded Cryptographic Key
The product uses a hard-coded, unchangeable cryptographic key.
Last updated
Overview
CWE-321 (Use of Hard-coded Cryptographic Key) is a variant-level software weakness catalogued by MITRE in the Common Weakness Enumeration (CWE). It describes a recurring type of mistake that can lead to exploitable security vulnerabilities.
Real-world CVEs
398 recorded CVEs are caused by CWE-321 (Use of Hard-coded Cryptographic Key), including 2 in CISA's KEV (Known Exploited Vulnerabilities) catalog. KEVs are shown first. 176 new CWE-321 CVEs have been recorded so far in 2026 (88 in 2025).
- CVE-2025-30406CISA KEVCritical · CVSS 9.5 · EPSS 100th2025-04-03
- CVE-2016-4437CISA KEV
Improper Access Control in Apache Shiro
Critical · CVSS 9.3 · EPSS 100th2016-06-07 - CVE-2026-86708
Sensitive data exposure
Critical · CVSS 10.0 · EPSS 86th2026-09-23 - CVE-2025-34256
Advantech WISE-DeviceOn Server < 5.4 Hard-coded JWT Key Authentication Bypass
Critical · CVSS 10.0 · EPSS 55th2025-12-05 - CVE-2025-12599
Multiple Devices are Sharing the Same Secrets for SDKSocket (TCP/5000)
Critical · CVSS 10.0 · EPSS 37th2025-11-01 - CVE-2025-34217
Vasion Print (formerly PrinterLogic) Undocumented Hardcoded SSH Key
Critical · CVSS 10.0 · EPSS 55th2025-09-30 - CVE-2024-30207Critical · CVSS 10.0 · EPSS 58th2024-05-14
- CVE-2016-9335Critical · CVSS 10.0 · EPSS 75th2018-05-09
- CVE-2017-7574Critical · CVSS 10.0 · EPSS 70th2017-04-06
- CVE-2014-5419
GE Multilink Use of Hard-coded Cryptographic Key
Critical · CVSS 10.0 · EPSS 84th2015-01-17 - CVE-2024-35344Critical · CVSS 9.9 · EPSS 31th2024-05-28
- CVE-2026-61737
ng-antd-admin: Hardcoded JWT Secret allows Authentication Bypass in ng-antd-admin
Critical · CVSS 9.8 · EPSS 44th2026-10-30
Showing 12 of 398 recorded CWE-321 CVEs. Get an alert for each new one, with AI-written analysis and fixes.
Monitor these CVEsCommon consequences
What can happen when CWE-321 is exploited.
Bypass Protection Mechanism, Gain Privileges or Assume Identity, Read Application Data
Affects: Access Control
If hard-coded cryptographic keys are used, it is almost certain that malicious users will gain access through the account in question. The use of a hard-coded cryptographic key significantly increases the possibility that encrypted data may be recovered.
How it happens
When it is introduced
Typically introduced during these phases of the software lifecycle.
Applies to
Technologies
How to prevent it
Practical mitigations for CWE-321, grouped by where in the lifecycle they apply.
Prevention schemes mirror that of hard-coded password storage.
How to detect it
Automated Static Analysis
Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
Effectiveness: High
Code examples
MITRE examples of the weakness in code.
The following code examples attempt to verify a password using a hard-coded cryptographic key.
Vulnerable example
int VerifyAdmin(char *password) {
if (strcmp(password,"68af404b513073584c4b6f22b6c63e6b")) {Vulnerable example
public boolean VerifyAdmin(String password) {
if (password.equals("68af404b513073584c4b6f22b6c63e6b")) {
System.out.println("Entering Diagnostic Mode...");Vulnerable example
int VerifyAdmin(String password) {
if (password.Equals("68af404b513073584c4b6f22b6c63e6b")) {
Console.WriteLine("Entering Diagnostic Mode...");The cryptographic key is within a hard-coded string value that is compared to the password. It is likely that an attacker will be able to read the key and compromise the system.
In 2022, the OT:ICEFALL study examined products by 10 different Operational Technology (OT) vendors. The researchers reported 56 vulnerabilities and said that the products were "insecure by design" [2]. If exploited, these vulnerabilities often allowed adversaries to change how the products operated, ranging from denial of service to changing the code that the products executed. Since these products were often used in industries such as power, electrical, water, and others, there could even be safety implications.
Multiple vendors used hard-coded keys for critical functionality in their OT products.
Illustrative examples
Real CVEs that MITRE cites as examples of this weakness.
- CVE-2022-29960 — Engineering Workstation uses hard-coded cryptographic keys that could allow for unathorized filesystem access and privilege escalation
- CVE-2022-30271 — Remote Terminal Unit (RTU) uses a hard-coded SSH private key that is likely to be used by default.
- CVE-2020-10884 — WiFi router service has a hard-coded encryption key, allowing root access
- CVE-2014-2198 — Communications / collaboration product has a hardcoded SSH private key, allowing access to root account
Terminology & mappings
Mapped taxonomies
- CLASP: Use of hard-coded cryptographic key
- OWASP Top Ten 2007: Insecure Cryptographic Storage (A8) — CWE More Specific fit
- OWASP Top Ten 2007: Insecure Communications (A9) — CWE More Specific fit
- OWASP Top Ten 2004: Insecure Storage (A8) — CWE More Specific fit
- Software Fault Patterns: Hardcoded sensitive data (SFP33)
- ISA/IEC 62443: Req SP.03.10 RE(1) (Part 2-4)
- ISA/IEC 62443: Req SP.03.10 RE(3) (Part 2-4)
- ISA/IEC 62443: Req SR 1.5 (Part 3-3)
- ISA/IEC 62443: Req SR 4.3 (Part 3-3)
- ISA/IEC 62443: Req SD-1 (Part 4-1)
- ISA/IEC 62443: Req SR 4.3 (Part 4-2)
- ISA/IEC 62443: Req CR 7.3 (Part 4-2)
Frequently asked questions
Common questions about CWE-321.
- What is CWE-321?
- The product uses a hard-coded, unchangeable cryptographic key.
- What CVEs are caused by CWE-321?
- 398 recorded CVEs are attributed to CWE-321, including CVE-2025-30406, CVE-2016-4437 and CVE-2026-86708. 2 are listed in CISA's Known Exploited Vulnerabilities (KEV) catalog.
- Is CWE-321 part of the OWASP Top 10?
- CWE-321 maps to OWASP Top Ten 2007: Insecure Cryptographic Storage (A8) in the OWASP security taxonomy.
- How do you prevent CWE-321?
- Prevention schemes mirror that of hard-coded password storage.
- How is CWE-321 detected?
- Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
- What are the consequences of CWE-321?
- Exploiting CWE-321 can lead to: Bypass Protection Mechanism, Gain Privileges or Assume Identity, Read Application Data.
- Is CWE-321 actively exploited?
- Yes. 2 CWE-321 vulnerabilities are in CISA's KEV catalog of actively exploited flaws, out of 398 recorded CVEs.
Sources
References
- MITRE CWE definition (CWE-321) (opens in a new tab)
- CWE-321 vulnerabilities on NVD (opens in a new tab)
- Learn: What is a CWE?
Weakness data is sourced from the MITRE CWE catalog (v4.20). CVE associations are aggregated and kept current by RadicalNotion.AI.
Track CWE-321 CVEs
Get an alert when a new CWE-321 CVE affects your products, with AI-written analysis and remediation steps.