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.|
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.
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.
|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|