CWE-312: Cleartext Storage of Sensitive Information
Official CWE-312 CWE context with Glexia analysis, remediation guidance, related CVEs, and ATT&CK context.
Glexia's Take
CWE-312: Cleartext Storage of Sensitive Information
Cleartext Storage of Sensitive Information represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.
Executive Impact
- Confidentiality: Read Application Data: An attacker with access to the system could read sensitive information stored in cleartext (i.e., unencrypted). Even if the information is encoded in a way that is not human-readable, certain techniques could determine which encoding is being used, then decode the information.
Developer Pattern
CWE-312 is the kind of defect developers can usually prevent with explicit validation, safer framework defaults, and tests that exercise hostile input or unsafe state transitions.
Confidence
high confidence from CWE-312, 4.20.
Official CWE Definition
CWE-312: Cleartext Storage of Sensitive Information
The product stores sensitive information in cleartext within a resource that might be accessible to another control sphere.
Developer And Remediation Guidance
How teams prevent and detect this weakness
Causes
- The following code excerpt stores a plaintext user account ID in a browser cookie. Because the account ID is in plaintext, the user's account information is exposed if their computer is compromised by an attacker.
- This code writes a user's login information to a cookie so the user does not have to login again later. The code stores the user's username and password in plaintext in a cookie on the user's machine. This exposes the user's login information if their computer is compromised by an attacker. Even if the user's machine is not compromised, this weakness combined with cross-site scripting (CWE-79) could allow an attacker to remotely copy the cookie.,Also note this example code also exhibits Plaintext Storage in a Cookie (CWE-315).
- The following code attempts to establish a connection, read in a password, then store it to a buffer. While successful, the program does not encrypt the data before writing it to a buffer, possibly exposing it to unauthorized actors.
- The following examples show a portion of properties and configuration files for Java and ASP.NET applications. The files include username and password information but they are stored in cleartext. This Java example shows a properties file with a cleartext username / password pair.,The following example shows a portion of a configuration file for an ASP.Net application. This configuration file includes username and password information for a connection to a database but the pair is stored in cleartext.,Username and password information should not be included in a configuration file or a properties file in cleartext as this will allow anyone who can read the file access to the resource. If possible, encrypt this information.
- 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. At least one OT product stored a password in plaintext.
- In 2021, a web site operated by PeopleGIS stored data of US municipalities in Amazon Web Service (AWS) Simple Storage Service (S3) buckets. While it was not publicly disclosed how the data was protected after discovery, multiple options could have been considered.
Remediation
- Implementation,System Configuration,Operation: When storing data in the cloud (e.g., S3 buckets, Azure blobs, Google Cloud Storage, etc.), use the provider's controls to encrypt the data at rest. [REF-1297] [REF-1299] [REF-1301]
- Implementation,System Configuration,Operation: In some systems/environments such as cloud, the use of "double encryption" (at both the software and hardware layer) might be required, and the developer might be solely responsible for both layers, instead of shared responsibility with the administrator of the broader system/environment.
Detection
- 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.)
Mappings
Related CVEs, CWEs, and ATT&CK context
Related CWEs
- CWE-311: Missing Encryption of Sensitive Data
- CWE-311: Missing Encryption of Sensitive Data
- CWE-922: Insecure Storage of Sensitive Information
- CWE-313: Cleartext Storage in a File or on Disk
- CWE-314: Cleartext Storage in the Registry
- CWE-315: Cleartext Storage of Sensitive Information in a Cookie
- CWE-316: Cleartext Storage of Sensitive Information in Memory
- CWE-317: Cleartext Storage of Sensitive Information in GUI
- CWE-318: Cleartext Storage of Sensitive Information in Executable
- CWE-526: Cleartext Storage of Sensitive Information in an Environment Variable
ATT&CK Relevance
ATT&CK relevance is shown only when reviewed or responsibly inferred.