---
title: "CWE-321: Use of Hard-coded Cryptographic Key"
url: https://radicalnotion.ai/cwe/cwe-321
type: cwe
description: "The product uses a hard-coded, unchangeable cryptographic key."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-321: Use of Hard-coded Cryptographic Key

- **Abstraction:** Variant
- **Structure:** Simple
- **Status:** Draft
- **Likelihood of exploit:** High
- **CVEs with this as primary weakness:** 444
- **Of those, in CISA KEV:** 2
- **New in 2026:** 210
- **CWE catalog version:** 4.21

## Description

The product uses a hard-coded, unchangeable cryptographic key.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Architecture and Design | REALIZATION: This weakness is caused during implementation of an architectural security tactic. |

## Applicable platforms

**Languages:** Go (Undetermined)

**Technologies:** ICS/OT (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Access Control | Bypass Protection Mechanism, Gain Privileges or Assume Identity, Read Application Data | 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. |

## Potential mitigations

### Architecture and Design

Prevention schemes mirror that of hard-coded password storage.

## Detection methods

### 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

## Demonstrative examples

### Example 1

The following code examples attempt to verify a password using a hard-coded cryptographic key.

Bad code:

```c
int VerifyAdmin(char *password) {
    if (strcmp(password,"68af404b513073584c4b6f22b6c63e6b")) {

        printf("Incorrect Password!\n");
        return(0);
    }
    printf("Entering Diagnostic Mode...\n");
    return(1);
}
```

Bad code:

```java
public boolean VerifyAdmin(String password) {
    if (password.equals("68af404b513073584c4b6f22b6c63e6b")) {
        System.out.println("Entering Diagnostic Mode...");
        return true;
    }
    System.out.println("Incorrect Password!");
    return false;
```

Bad code:

```c#
int VerifyAdmin(String password) {
    if (password.Equals("68af404b513073584c4b6f22b6c63e6b")) {
        Console.WriteLine("Entering Diagnostic Mode...");
        return(1);
    }
    Console.WriteLine("Incorrect Password!");
    return(0);
}
```

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.

### Example 2

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" \[REF-1283\]. 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.

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2022-29960 | Engineering Workstation uses hard-coded cryptographic keys that could allow for unauthorized 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 in typical deployments. |
| 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 |

## Real CVEs with this weakness (sample of 12 of 444)

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2025-30406 | Gladinet CentreStack and Triofox Use of Hard-coded Cryptographic Key Vulnerability | critical | 9.5 | - | Yes | 2025-04-03 |
| CVE-2016-4437 | Improper Access Control in Apache Shiro | critical | 9.3 | - | Yes | 2016-06-07 |
| CVE-2026-114202 | - | critical | 10.0 | - | No | 2026-11-18 |
| CVE-2026-86708 | Sensitive data exposure | critical | 10.0 | - | No | 2026-09-23 |
| CVE-2025-34256 | Advantech WISE-DeviceOn Server \< 5.4 Hard-coded JWT Key Authentication Bypass | critical | 10.0 | - | No | 2025-12-05 |
| CVE-2025-12599 | Multiple Devices are Sharing the Same Secrets for SDKSocket (TCP/5000) | critical | 10.0 | - | No | 2025-11-01 |
| CVE-2025-34217 | Vasion Print (formerly PrinterLogic) Undocumented Hardcoded SSH Key | critical | 10.0 | - | No | 2025-09-30 |
| CVE-2024-30207 | Use of Hard-coded Cryptographic Key in Siemens SIMATIC RTLS Locating Manager | critical | 10.0 | - | No | 2024-05-14 |
| CVE-2016-9335 | Use of Hard-coded Cryptographic Key in Red Lion Controls Sixnet-Managed Industrial Switches, AutomationDirect STRIDE-Managed Ethernet Switches | critical | 10.0 | - | No | 2018-05-09 |
| CVE-2017-7574 | Use of Hard-coded Cryptographic Key in Schneider Electric Modicon M221 PLCs and SoMachine Basic | critical | 10.0 | - | No | 2017-04-06 |
| CVE-2014-5419 | GE Multilink Use of Hard-coded Cryptographic Key | critical | 10.0 | - | No | 2015-01-17 |
| CVE-2024-35344 | - | critical | 9.9 | - | No | 2024-05-28 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-798](https://radicalnotion.ai/cwe/cwe-798) | Use of Hard-coded Credentials |
| Peer | [CWE-259](https://radicalnotion.ai/cwe/cwe-259) | Use of Hard-coded Password |
| Peer | [CWE-1291](https://radicalnotion.ai/cwe/cwe-1291) | Public Key Re-Use for Signing both Debug and Production Code |
| Related | [CWE-656](https://radicalnotion.ai/cwe/cwe-656) | Reliance on Security Through Obscurity |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| CLASP | Use of hard-coded cryptographic key | - | - |
| OWASP Top Ten 2007 | Insecure Cryptographic Storage | A8 | CWE More Specific |
| OWASP Top Ten 2007 | Insecure Communications | A9 | CWE More Specific |
| OWASP Top Ten 2004 | Insecure Storage | A8 | CWE More Specific |
| 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 | - |
| OWASP Golang Secure Coding Practices Guide | Cryptographic Practices | - | - |

## Frequently asked questions

### What is CWE-321?

The product uses a hard-coded, unchangeable cryptographic key.

### What CVEs are caused by CWE-321?

444 recorded CVEs are attributed to CWE-321, including CVE-2025-30406, CVE-2016-4437 and CVE-2026-114202. 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 444 recorded CVEs.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/321.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-321). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
