CWE-321: Use of Hard-coded Cryptographic Key Weakness ID: 321 Vulnerability Mapping:
ALLOWEDThis CWE ID may be used to map to real-world vulnerabilities Abstraction: VariantVariant - a weakness that is linked to a certain type of product, typically involving a specific language or technology. More specific than a Base weakness. Variant level weaknesses typically describe issues in terms of 3 to 5 of the following dimensions: behavior, property, technology, language, and resource. |
Description The use of a hard-coded cryptographic key significantly increases the possibility that encrypted data may be recovered. Relationships This table shows the weaknesses and high level categories that are related to this weakness. These relationships are defined as ChildOf, ParentOf, MemberOf and give insight to similar items that may exist at higher and lower levels of abstraction. In addition, relationships such as PeerOf and CanAlsoBe are defined to show similar weaknesses that the user may want to explore. Relevant to the view "Research Concepts" (CWE-1000) Nature | Type | ID | Name |
---|
ChildOf | Base - a weakness
that is still mostly independent of a resource or technology, but with sufficient details to provide specific methods for detection and prevention. Base level weaknesses typically describe issues in terms of 2 or 3 of the following dimensions: behavior, property, technology, language, and resource. | 798 | Use of Hard-coded Credentials | PeerOf | Variant - a weakness
that is linked to a certain type of product, typically involving a specific language or technology. More specific than a Base weakness. Variant level weaknesses typically describe issues in terms of 3 to 5 of the following dimensions: behavior, property, technology, language, and resource. | 259 | Use of Hard-coded Password | PeerOf | Base - a weakness
that is still mostly independent of a resource or technology, but with sufficient details to provide specific methods for detection and prevention. Base level weaknesses typically describe issues in terms of 2 or 3 of the following dimensions: behavior, property, technology, language, and resource. | 1291 | Public Key Re-Use for Signing both Debug and Production Code | CanFollow | Class - a weakness that is described in a very abstract fashion, typically independent of any specific language or technology. More specific than a Pillar Weakness, but more general than a Base Weakness. Class level weaknesses typically describe issues in terms of 1 or 2 of the following dimensions: behavior, property, and resource. | 656 | Reliance on Security Through Obscurity |
This table shows the weaknesses and high level categories that are related to this weakness. These relationships are defined as ChildOf, ParentOf, MemberOf and give insight to similar items that may exist at higher and lower levels of abstraction. In addition, relationships such as PeerOf and CanAlsoBe are defined to show similar weaknesses that the user may want to explore. Relevant to the view "Architectural Concepts" (CWE-1008) Nature | Type | ID | Name |
---|
MemberOf | Category - a CWE entry that contains a set of other entries that share a common characteristic. | 1013 | Encrypt Data |
This table shows the weaknesses and high level categories that are related to this weakness. These relationships are defined as ChildOf, ParentOf, MemberOf and give insight to similar items that may exist at higher and lower levels of abstraction. In addition, relationships such as PeerOf and CanAlsoBe are defined to show similar weaknesses that the user may want to explore. Relevant to the view "CISQ Quality Measures (2020)" (CWE-1305) Nature | Type | ID | Name |
---|
ChildOf | Base - a weakness
that is still mostly independent of a resource or technology, but with sufficient details to provide specific methods for detection and prevention. Base level weaknesses typically describe issues in terms of 2 or 3 of the following dimensions: behavior, property, technology, language, and resource. | 798 | Use of Hard-coded Credentials |
This table shows the weaknesses and high level categories that are related to this weakness. These relationships are defined as ChildOf, ParentOf, MemberOf and give insight to similar items that may exist at higher and lower levels of abstraction. In addition, relationships such as PeerOf and CanAlsoBe are defined to show similar weaknesses that the user may want to explore. Relevant to the view "CISQ Data Protection Measures" (CWE-1340) Nature | Type | ID | Name |
---|
ChildOf | Base - a weakness
that is still mostly independent of a resource or technology, but with sufficient details to provide specific methods for detection and prevention. Base level weaknesses typically describe issues in terms of 2 or 3 of the following dimensions: behavior, property, technology, language, and resource. | 798 | Use of Hard-coded Credentials |
Modes Of Introduction The different Modes of Introduction provide information about how and when this weakness may be introduced. The Phase identifies a point in the life cycle at which introduction may occur, while the Note provides a typical scenario related to introduction during the given phase.Phase | Note |
---|
Architecture and Design | REALIZATION: This weakness is caused during implementation of an architectural security tactic. |
Common Consequences This table specifies different individual consequences associated with the weakness. The Scope identifies the application security area that is violated, while the Impact describes the negative technical impact that arises if an adversary succeeds in exploiting this weakness. The Likelihood provides information about how likely the specific consequence is expected to be seen relative to the other consequences in the list. For example, there may be high likelihood that a weakness will be exploited to achieve a certain impact, but a low likelihood that it will be exploited to achieve a different impact.Scope | Impact | Likelihood |
---|
Access Control
| Technical Impact: Bypass Protection Mechanism; Gain Privileges or Assume Identity If hard-coded cryptographic keys are used, it is almost certain that malicious users will gain access through the account in question. | |
Likelihood Of Exploit Demonstrative Examples Example 1 The following code examples attempt to verify a password using a hard-coded cryptographic key. (bad code) Example Language: C
int VerifyAdmin(char *password) {
if (strcmp(password,"68af404b513073584c4b6f22b6c63e6b")) {
printf("Incorrect Password!\n"); return(0);
} printf("Entering Diagnostic Mode...\n"); return(1);
}
(bad code) Example Language: 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) Example Language: 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 Reference | Description |
| Engineering Workstation uses hard-coded cryptographic keys that could allow for unathorized filesystem access and privilege escalation |
| Remote Terminal Unit (RTU) uses a hard-coded SSH private key that is likely to be used by default. |
| WiFi router service has a hard-coded encryption key, allowing root access |
| Communications / collaboration product has a hardcoded SSH private key, allowing access to root account |
Potential Mitigations
Phase: 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.) |
Memberships This MemberOf Relationships table shows additional CWE Categories and Views that reference this weakness as a member. This information is often useful in understanding where a weakness fits within the context of external information sources. Vulnerability Mapping Notes Usage: ALLOWED (this CWE ID could be used to map to real-world vulnerabilities) | Reason: Acceptable-Use | Rationale: This CWE entry is at the Variant level of abstraction, which is a preferred level of abstraction for mapping to the root causes of vulnerabilities. | Comments: Carefully read both the name and description to ensure that this mapping is an appropriate fit. Do not try to 'force' a mapping to a lower-level Base/Variant simply to comply with this preferred level of abstraction. |
Notes Other The main difference between the use of hard-coded passwords and the use of hard-coded cryptographic keys is the false sense of security that the former conveys. Many people believe that simply hashing a hard-coded password before storage will protect the information from malicious users. However, many hashes are reversible (or at least vulnerable to brute force attacks) -- and further, many authentication protocols simply request the hash itself, making it no better than a password. Maintenance The Taxonomy_Mappings to ISA/IEC 62443 were added in CWE 4.10, but they are still under review and might change in future CWE versions. These draft mappings were performed by members of the "Mapping CWE to 62443" subgroup of the CWE-CAPEC ICS/OT Special Interest Group (SIG), and their work is incomplete as of CWE 4.10. The mappings are included to facilitate discussion and review by the broader ICS/OT community, and they are likely to change in future CWE versions. Taxonomy Mappings Mapped Taxonomy Name | Node ID | Fit | Mapped Node Name |
CLASP | | | Use of hard-coded cryptographic key |
OWASP Top Ten 2007 | A8 | CWE More Specific | Insecure Cryptographic Storage |
OWASP Top Ten 2007 | A9 | CWE More Specific | Insecure Communications |
OWASP Top Ten 2004 | A8 | CWE More Specific | Insecure Storage |
Software Fault Patterns | SFP33 | | Hardcoded sensitive data |
ISA/IEC 62443 | Part 2-4 | | Req SP.03.10 RE(1) |
ISA/IEC 62443 | Part 2-4 | | Req SP.03.10 RE(3) |
ISA/IEC 62443 | Part 3-3 | | Req SR 1.5 |
ISA/IEC 62443 | Part 3-3 | | Req SR 4.3 |
ISA/IEC 62443 | Part 4-1 | | Req SD-1 |
ISA/IEC 62443 | Part 4-2 | | Req SR 4.3 |
ISA/IEC 62443 | Part 4-2 | | Req CR 7.3 |
References Content History Submissions |
---|
Submission Date | Submitter | Organization |
---|
2006-07-19 (CWE Draft 3, 2006-07-19) | CLASP | | | Contributions |
---|
Contribution Date | Contributor | Organization |
---|
2023-01-24 (CWE 4.10, 2023-01-31) | "Mapping CWE to 62443" Sub-Working Group | CWE-CAPEC ICS/OT SIG | Suggested mappings to ISA/IEC 62443. | 2023-04-25 | "Mapping CWE to 62443" Sub-Working Group | CWE-CAPEC ICS/OT SIG | Suggested mappings to ISA/IEC 62443. | Modifications |
---|
Modification Date | Modifier | Organization |
---|
2008-07-01 | Eric Dalci | Cigital | updated Time_of_Introduction | 2008-08-15 | | Veracode | Suggested OWASP Top Ten 2004 mapping | 2008-09-08 | CWE Content Team | MITRE | updated Common_Consequences, Relationships, Other_Notes, Taxonomy_Mappings | 2009-05-27 | CWE Content Team | MITRE | updated Demonstrative_Examples | 2010-02-16 | CWE Content Team | MITRE | updated Relationships | 2010-09-27 | CWE Content Team | MITRE | updated Relationships | 2010-12-13 | CWE Content Team | MITRE | updated Relationships | 2011-06-01 | CWE Content Team | MITRE | updated Common_Consequences | 2012-05-11 | CWE Content Team | MITRE | updated Demonstrative_Examples, Relationships | 2014-07-30 | CWE Content Team | MITRE | updated Demonstrative_Examples, Relationships, Taxonomy_Mappings | 2017-11-08 | CWE Content Team | MITRE | updated Applicable_Platforms, Demonstrative_Examples, Modes_of_Introduction, Relationships | 2020-02-24 | CWE Content Team | MITRE | updated References, Relationships, Type | 2020-08-20 | CWE Content Team | MITRE | updated Relationships | 2020-12-10 | CWE Content Team | MITRE | updated Relationships | 2021-10-28 | CWE Content Team | MITRE | updated Relationships | 2022-10-13 | CWE Content Team | MITRE | updated Demonstrative_Examples, Observed_Examples, References | 2023-01-31 | CWE Content Team | MITRE | updated Applicable_Platforms, Maintenance_Notes, Taxonomy_Mappings | 2023-04-27 | CWE Content Team | MITRE | updated Detection_Factors, Relationships, Taxonomy_Mappings | 2023-06-29 | CWE Content Team | MITRE | updated Mapping_Notes, Taxonomy_Mappings |
More information is available — Please edit the custom filter or select a different filter.
|