Class · High

CWE-311: Missing Encryption of Sensitive Data

The product does not encrypt sensitive or critical information before storage or transmission.

CWE-311 · Class Level ·21 CVEs ·6 Mitigations

Description

The product does not encrypt sensitive or critical information before storage or transmission.

Potential Impact

Confidentiality

Read Application Data

Confidentiality, Integrity

Modify Application Data

Demonstrative Examples

This code writes a user's login information to a cookie so the user does not have to login again later.
Bad
function persistLogin($username, $password){$data = array("username" => $username, "password"=> $password);setcookie ("userdata", $data);}
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.
Bad
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);...
While successful, the program does not encrypt the data before writing it to a buffer, possibly exposing it to unauthorized actors.
The following code attempts to establish a connection to a site to communicate sensitive information.
Bad
try {URL u = new URL("http://www.secret.example.org/");HttpURLConnection hu = (HttpURLConnection) u.openConnection();hu.setRequestMethod("PUT");hu.connect();OutputStream os = hu.getOutputStream();hu.disconnect();}catch (IOException e) {
                        
                           
                           //...
                           
                        
                     }
Though a connection is successfully made, the connection is unencrypted and it is possible that all sensitive data sent to or received from the server will be read by unintended actors.

Mitigations & Prevention

Requirements

Clearly specify which data or resources are valuable enough that they should be protected by encryption. Require that any transmission or storage of this data/resource should use well-vetted encryption algorithms.

Architecture and Design

Ensure that encryption is properly integrated into the system design, including but not necessarily limited to: Identify the separate needs and contexts for encryption: Using threat modeling or other techniques, assume that data can be compromised through a separate vulnerability or weakness, and determine where encryption will be most effective. Ensure that d

Architecture and Design

When there is a need to store or transmit sensitive data, use strong, up-to-date cryptographic algorithms to encrypt that data. Select a well-vetted algorithm that is currently considered to be strong by experts in the field, and use well-tested implementations. As with all cryptographic mechanisms, the source code should be available for analysis. For example, US government systems require FIPS 140-2 certification. Do not develop custom or private cryptog

Architecture and Design

Compartmentalize the system to have "safe" areas where trust boundaries can be unambiguously drawn. Do not allow sensitive data to go outside of the trust boundary and always be careful when interfacing with a compartment outside of the safe area. Ensure that appropriate compartmentalization is built into the system design, and the compartmentalization allows for and reinforces privilege separation functionality. Architects and designers should rely on the principle of least

ImplementationArchitecture and Design

When using industry-approved techniques, use them correctly. Don't cut corners by skipping resource-intensive steps (CWE-325). These steps are often essential for preventing common attacks.

Implementation Defense in Depth

Use naming conventions and strong types to make it easier to spot when sensitive data is being used. When creating structures, objects, or other complex entities, separate the sensitive and non-sensitive data as much as possible.

Detection Methods

  • Manual Analysis High — The characterizaton of sensitive data often requires domain-specific understanding, so manual methods are useful. However, manual efforts might not achieve desired code coverage within limited time constraints. Black box methods may produce artifacts (e.g. stored data or unencrypted network transfer
  • Automated Analysis — Automated measurement of the entropy of an input/output source may indicate the use or lack of encryption, but human analysis is still required to distinguish intentionally-unencrypted data (e.g. metadata) from sensitive data.
  • Manual Static Analysis - Binary or Bytecode SOAR Partial — According to SOAR [REF-1479], the following detection techniques may be useful:
  • Dynamic Analysis with Automated Results Interpretation SOAR Partial — According to SOAR [REF-1479], the following detection techniques may be useful:
  • Dynamic Analysis with Manual Results Interpretation High — According to SOAR [REF-1479], the following detection techniques may be useful:
  • Manual Static Analysis - Source Code High — According to SOAR [REF-1479], the following detection techniques may be useful:

Real-World CVE Examples

CVE IDDescription
CVE-2022-26390wireless battery product stores credentials and Personal Health Information (PHI) without encryption
CVE-2009-2272password and username stored in cleartext in a cookie
CVE-2009-1466password stored in cleartext in a file with insecure permissions
CVE-2009-0152chat program disables SSL in some circumstances even when the user says to use SSL.
CVE-2009-1603Chain: product uses an incorrect public exponent when generating an RSA key, which effectively disables the encryption
CVE-2009-0964storage of unencrypted passwords in a database
CVE-2008-6157storage of unencrypted passwords in a database
CVE-2008-6828product stores a password in cleartext in memory
CVE-2008-1567storage of a secret key in cleartext in a temporary file
CVE-2008-0174SCADA product uses HTTP Basic Authentication, which is not encrypted
CVE-2007-5778login credentials stored unencrypted in a registry key
CVE-2002-1949Passwords transmitted in cleartext.
CVE-2008-4122Chain: Use of HTTPS cookie without "secure" flag causes it to be transmitted across unencrypted HTTP.
CVE-2008-3289Product sends password hash in cleartext in violation of intended policy.
CVE-2008-4390Remote management feature sends sensitive information including passwords in cleartext.

Showing 15 of 21 observed examples.

Taxonomy Mappings

  • CLASP: — Failure to encrypt data
  • OWASP Top Ten 2007: A8 — Insecure Cryptographic Storage
  • OWASP Top Ten 2007: A9 — Insecure Communications
  • OWASP Top Ten 2004: A8 — Insecure Storage
  • WASC: 4 — Insufficient Transport Layer Protection
  • The CERT Oracle Secure Coding Standard for Java (2011): MSC00-J — Use SSLSocket rather than Socket for secure data exchange
  • Software Fault Patterns: SFP23 — Exposed Data
  • ISA/IEC 62443: Part 3-3 — Req SR 4.1
  • ISA/IEC 62443: Part 3-3 — Req SR 4.3
  • ISA/IEC 62443: Part 4-2 — Req CR 4.1
  • ISA/IEC 62443: Part 4-2 — Req CR 7.3
  • ISA/IEC 62443: Part 4-2 — Req CR 1.5

Frequently Asked Questions

What is CWE-311?

CWE-311 (Missing Encryption of Sensitive Data) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Class-level weakness. The product does not encrypt sensitive or critical information before storage or transmission.

How can CWE-311 be exploited?

Attackers can exploit CWE-311 (Missing Encryption of Sensitive Data) to read application data. This weakness is typically introduced during the Architecture and Design, Operation phase of software development.

How do I prevent CWE-311?

Key mitigations include: Clearly specify which data or resources are valuable enough that they should be protected by encryption. Require that any transmission or storage of this data/resource should use well-vetted encryptio

What is the severity of CWE-311?

CWE-311 is classified as a Class-level weakness (High abstraction). It has been observed in 21 real-world CVEs.