CWE-532 通过日志文件的信息暴露

admin 2021年12月16日16:17:24评论110 views字数 3784阅读12分36秒阅读模式

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

logger.info("Username: " + usernme + ", CCN: " + ccn);

This code stores location information about the current user:

bad Java

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());

}

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

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;

}

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中文网

免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年12月16日16:17:24
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   CWE-532 通过日志文件的信息暴露https://cn-sec.com/archives/613122.html
                  免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉.

发表评论

匿名网友 填写信息