CWE-532 通过日志文件的信息暴露
Inclusion of Sensitive Information in Log Files
结构: Simple
Abstraction: Variant
状态: Incomplete
被利用可能性: Medium
基本描述
Information written to log files can be of a sensitive nature and give valuable guidance to an attacker or expose sensitive user information.
扩展描述
While logging all information may be helpful during development stages, it is important that logging levels be set appropriately before a product ships so that sensitive user data and system information are not accidentally exposed to potential attackers.
Different log files may be produced and stored for:
相关缺陷
-
cwe_Nature: ChildOf cwe_CWE_ID: 538 cwe_View_ID: 1000 cwe_Ordinal: Primary
-
cwe_Nature: ChildOf cwe_CWE_ID: 538 cwe_View_ID: 699 cwe_Ordinal: Primary
-
cwe_Nature: ChildOf cwe_CWE_ID: 200 cwe_View_ID: 1003 cwe_Ordinal: Primary
-
cwe_Nature: ChildOf cwe_CWE_ID: 552 cwe_View_ID: 1000
-
cwe_Nature: ChildOf cwe_CWE_ID: 552 cwe_View_ID: 699
常见的影响
范围 | 影响 | 注释 |
---|---|---|
Confidentiality | Read Application Data | Logging sensitive user data often provides attackers with an additional, less-protected path to acquiring the information. |
可能的缓解方案
['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.
示例代码
例
In the following code snippet, a user's full name and credit card number are written to a log file.
bad Java
例
This code stores location information about the current user:
bad Java
locationClient.connect();
currentUser.setLocation(locationClient.getLastLocation());
...
catch (Exception e) {
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());
}
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.
bad Java
String query = null;
try {
+ 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) {
Logger.getLogger(BankManager.class.getName()).log(Level.SEVERE, logMessage, ex);
}
return userAccount;
}
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.
分析过的案例
标识 | 说明 | 链接 |
---|---|---|
CVE-2017-9615 | verbose logging stores admin credentials in a world-readablelog file | https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-9615 |
CVE-2018-1999036 | SSH password for private key stored in build log | https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-1999036 |
分类映射
映射的分类名 | ImNode ID | Fit | Mapped Node Name |
---|---|---|---|
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 |
相关攻击模式
- CAPEC-215
文章来源于互联网:scap中文网
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论