Description
The product stores sensitive information in cleartext within a resource that might be accessible to another control sphere.
Sensitive Data Exposure
Read our in-depth guide on exploiting and mitigating this weakness
Potential Impact
Confidentiality
Read Application Data
Demonstrative Examples
response.addCookie( new Cookie("userAccountID", acctID);function persistLogin($username, $password){$data = array("username" => $username, "password"=> $password);setcookie ("userdata", $data);}server.sin_family = AF_INET; hp = gethostbyname(argv[1]);if (hp==NULL) error("Unknown host");memcpy( (char *)&server.sin_addr,(char *)hp->h_addr,hp->h_length);if (argc < 3) port = 80;else port = (unsigned short)atoi(argv[3]);server.sin_port = htons(port);if (connect(sock, (struct sockaddr *)&server, sizeof server) < 0) error("Connecting");...while ((n=read(sock,buffer,BUFSIZE-1))!=-1) {
write(dfd,password_buffer,n);...# Java Web App ResourceBundle properties file
...webapp.ldap.username=secretUsernamewebapp.ldap.password=secretPassword......<connectionStrings><add name="ud_DEV" connectionString="connectDB=uDB; uid=db2admin; pwd=password; dbalias=uDB;" providerName="System.Data.Odbc" /></connectionStrings>...Mitigations & Prevention
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]
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 Methods
- Automated Static Analysis High — 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 sea
Real-World CVE Examples
| CVE ID | Description |
|---|---|
| CVE-2022-26390 | wireless battery product stores credentials and Personal Health Information (PHI) without encryption |
| CVE-2022-30275 | Remote Terminal Unit (RTU) uses a driver that relies on a password stored in plaintext. |
| CVE-2009-2272 | password and username stored in cleartext in a cookie |
| CVE-2009-1466 | password stored in cleartext in a file with insecure permissions |
| CVE-2009-0152 | chat program disables SSL in some circumstances even when the user says to use SSL. |
| CVE-2009-1603 | Chain: product uses an incorrect public exponent when generating an RSA key, which effectively disables the encryption |
| CVE-2009-0964 | storage of unencrypted passwords in a database |
| CVE-2008-6157 | storage of unencrypted passwords in a database |
| CVE-2008-6828 | product stores a password in cleartext in memory |
| CVE-2008-1567 | storage of a secret key in cleartext in a temporary file |
| CVE-2008-0174 | SCADA product uses HTTP Basic Authentication, which is not encrypted |
| CVE-2007-5778 | login credentials stored unencrypted in a registry key |
| CVE-2001-1481 | Plaintext credentials in world-readable file. |
| CVE-2005-1828 | Password in cleartext in config file. |
| CVE-2005-2209 | Password in cleartext in config file. |
Showing 15 of 21 observed examples.
Related Weaknesses
Taxonomy Mappings
- PLOVER: — Plaintext Storage of Sensitive Information
- Software Fault Patterns: SFP23 — Exposed Data
- ISA/IEC 62443: Part 4-2 — Req CR 4.1 a)
- ISA/IEC 62443: Part 3-3 — Req SR 4.1
Frequently Asked Questions
What is CWE-312?
CWE-312 (Cleartext Storage of Sensitive Information) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Base-level weakness. The product stores sensitive information in cleartext within a resource that might be accessible to another control sphere.
How can CWE-312 be exploited?
Attackers can exploit CWE-312 (Cleartext Storage of Sensitive Information) to read application data. This weakness is typically introduced during the Architecture and Design phase of software development.
How do I prevent CWE-312?
Key mitigations include: 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]
What is the severity of CWE-312?
CWE-312 is classified as a Base-level weakness (Medium abstraction). It has been observed in 21 real-world CVEs.