Base · Medium

CWE-256: Plaintext Storage of a Password

The product stores a password in plaintext within resources such as memory or files.

CWE-256 · Base Level ·1 CVEs ·3 Mitigations

Description

The product stores a password in plaintext within resources such as memory or files.

Potential Impact

Access Control

Gain Privileges or Assume Identity

Demonstrative Examples

The following code reads a password from a properties file and uses the password to connect to a database.
Bad
...Properties prop = new Properties();prop.load(new FileInputStream("config.properties"));String password = prop.getProperty("password");DriverManager.getConnection(url, usr, password);...
This code will run successfully, but anyone who has access to config.properties can read the value of password. If a devious employee has access to this information, they can use it to break into the system.
The following code reads a password from the registry and uses the password to create a new network credential.
Bad
...String password = regKey.GetValue(passKey).toString();NetworkCredential netCred = new NetworkCredential(username,password,domain);...
This code will run successfully, but anyone who has access to the registry key used to store the password can read the value of password. If a devious employee has access to this information, they can use it to break into the system
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.
Bad
# Java Web App ResourceBundle properties file
                     ...webapp.ldap.username=secretUsernamewebapp.ldap.password=secretPassword...
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.
Bad
...<connectionStrings><add name="ud_DEV" connectionString="connectDB=uDB; uid=db2admin; pwd=password; dbalias=uDB;" providerName="System.Data.Odbc" /></connectionStrings>...
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.

Mitigations & Prevention

Architecture and Design

Avoid storing passwords in easily accessible locations.

Architecture and Design

Consider storing cryptographic hashes of passwords as an alternative to storing in plaintext.

General None

A programmer might attempt to remedy the password management problem by obscuring the password with an encoding function, such as base 64 encoding, but this effort does not adequately protect the password because the encoding can be detected and decoded easily.

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 IDDescription
CVE-2022-30275Remote Terminal Unit (RTU) uses a driver that relies on a password stored in plaintext.

Taxonomy Mappings

  • 7 Pernicious Kingdoms: — Password Management
  • Software Fault Patterns: SFP23 — Exposed Data
  • ISA/IEC 62443: Part 4-2 — Req CR 1.5
  • ISA/IEC 62443: Part 3-3 — Req SR 1.5

Frequently Asked Questions

What is CWE-256?

CWE-256 (Plaintext Storage of a Password) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Base-level weakness. The product stores a password in plaintext within resources such as memory or files.

How can CWE-256 be exploited?

Attackers can exploit CWE-256 (Plaintext Storage of a Password) to gain privileges or assume identity. This weakness is typically introduced during the Architecture and Design, Architecture and Design phase of software development.

How do I prevent CWE-256?

Key mitigations include: Avoid storing passwords in easily accessible locations.

What is the severity of CWE-256?

CWE-256 is classified as a Base-level weakness (Medium abstraction). It has been observed in 1 real-world CVEs.