Description
The product writes sensitive information to a log file.
Potential Impact
Confidentiality
Read Application Data
Demonstrative Examples
logger.info("Username: " + usernme + ", CCN: " + ccn);locationClient = new LocationClient(this, this, this);locationClient.connect();currentUser.setLocation(locationClient.getLastLocation());
...
catch (Exception e) {AlertDialog.Builder builder = new AlertDialog.Builder(this);builder.setMessage("Sorry, this application has experienced an error.");AlertDialog alert = builder.create();alert.show();Log.e("ExampleActivity", "Caught exception: " + e + " While on User:" + User.toString());}public BankAccount getUserBankAccount(String username, String accountNumber) {
BankAccount userAccount = null;String query = null;try {if (isAuthorizedUser(username)) {query = "SELECT * FROM accounts WHERE owner = "+ username + " AND accountID = " + accountNumber;DatabaseManager dbManager = new DatabaseManager();Connection conn = dbManager.getConnection();Statement stmt = conn.createStatement();ResultSet queryResult = stmt.executeQuery(query);userAccount = (BankAccount)queryResult.getObject(accountNumber);}} catch (SQLException ex) {String logMessage = "Unable to retrieve account information from database,\nquery: " + query;Logger.getLogger(BankManager.class.getName()).log(Level.SEVERE, logMessage, ex);}return userAccount;
}Mitigations & Prevention
Consider seriously the sensitivity of the information written into log files. Do not write secrets into the log files.
Remove debug log files before deploying the application into production.
Protect log files against unauthorized read/write.
Adjust configurations appropriately when software is transitioned from a debug state to production.
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-2017-9615 | verbose logging stores admin credentials in a world-readable log file |
| CVE-2018-1999036 | SSH password for private key stored in build log |
Related Weaknesses
Taxonomy Mappings
- The CERT Oracle Secure Coding Standard for Java (2011): FIO13-J — Do not log sensitive information outside a trust boundary
- Software Fault Patterns: SFP23 — Exposed Data
Frequently Asked Questions
What is CWE-532?
CWE-532 (Insertion of Sensitive Information into Log File) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Base-level weakness. The product writes sensitive information to a log file.
How can CWE-532 be exploited?
Attackers can exploit CWE-532 (Insertion of Sensitive Information into Log File) to read application data. This weakness is typically introduced during the Architecture and Design, Implementation, Operation phase of software development.
How do I prevent CWE-532?
Key mitigations include: Consider seriously the sensitivity of the information written into log files. Do not write secrets into the log files.
What is the severity of CWE-532?
CWE-532 is classified as a Base-level weakness (Medium abstraction). It has been observed in 2 real-world CVEs.