CWE Reference
CWE-532: Insertion of Sensitive Information into Log File
Official CWE-532 CWE context with Glexia analysis, remediation guidance, related CVEs, and ATT&CK context.
Release 4.20weaknessIncomplete
Glexia's Take
CWE-532: Insertion of Sensitive Information into Log File
Insertion of Sensitive Information into Log File represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.
Executive Impact
- Confidentiality: 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.
Developer Pattern
CWE-532 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-532, 4.20.
Official CWE Definition
CWE-532: Insertion of Sensitive Information into Log File
The product writes sensitive information to a log file.
Developer And Remediation Guidance
How teams prevent and detect this weakness
Causes
- In the following code snippet, a user's full name and credit card number are written to a log file.
- This code stores location information about the current user: 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.
- 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. 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 (CWE-89) to directly access the database.
Remediation
- Architecture and Design,Implementation: Consider seriously the sensitivity of the information written into log files. Do not write secrets into the log files.
- Distribution: Remove debug log files before deploying the application into production.
- Operation: Protect log files against unauthorized read/write.
- Implementation: Adjust configurations appropriately when software is transitioned from a debug state to production.
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
ATT&CK Relevance
ATT&CK relevance is shown only when reviewed or responsibly inferred.