Insertion of Sensitive Information into Log File

Incomplete Base
Structure: Simple
Description

The product writes sensitive information to a log file.

The product writes sensitive information to a log file.
Common Consequences 1
Scope: Confidentiality

Impact: Read Application Data

Logging sensitive user data, full path names, or system information often provides attackers with an additional, less-protected path to acquiring the information.

Detection Methods 1
Automated Static AnalysisHigh
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.)
Potential Mitigations 4
Phase: Architecture and DesignImplementation
Consider seriously the sensitivity of the information written into log files. Do not write secrets into the log files.
Phase: Distribution
Remove debug log files before deploying the application into production.
Phase: Operation
Protect log files against unauthorized read/write.
Phase: Implementation
Adjust configurations appropriately when software is transitioned from a debug state to production.
Demonstrative Examples 3

ID : DX-179

In the following code snippet, a user's full name and credit card number are written to a log file.

Code Example:

Bad
Java
java

ID : DX-120

This code stores location information about the current user:

Code Example:

Bad
Java
java

...*

java
When the application encounters an exception it will write the user object to the log. Because the user object contains location information, the user's location is also written to the log.

ID : DX-119

In the example below, the method getUserBankAccount retrieves a bank account object from a database using the supplied username and account number to query the database. If an SQLException is raised when querying the database, an error message is created and output to a log file.

Code Example:

Bad
Java
java
The error message that is created includes information about the database query that may contain sensitive information about the database or query logic. In this case, the error message will expose the table name and column names used in the database. This data could be used to simplify other attacks, such as SQL injection (Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) to directly access the database.
Observed Examples 2
CVE-2017-9615verbose logging stores admin credentials in a world-readable log file
CVE-2018-1999036SSH password for private key stored in build log
Likelihood of Exploit

Medium

Modes of Introduction
Architecture and Design
Implementation
Operation
Taxonomy Mapping
  • The CERT Oracle Secure Coding Standard for Java (2011)
  • Software Fault Patterns