← 返回首页
Cleartext logging of sensitive information — CodeQL query help documentation CodeQL docs
CodeQL documentation
CodeQL resources

Cleartext logging of sensitive information

ID: swift/cleartext-logging Kind: path-problem Security severity: 7.5 Severity: error Precision: high Tags: - security - external/cwe/cwe-312 - external/cwe/cwe-359 - external/cwe/cwe-532 Query suites: - swift-code-scanning.qls - swift-security-extended.qls - swift-security-and-quality.qls

Click to see the query in the CodeQL repository

Attackers could gain access to sensitive information that is logged unencrypted.

Recommendation

Always make sure to encrypt or obfuscate sensitive information before you log it.

Generally, you should decrypt sensitive information only at the point where it is necessary for it to be used in cleartext.

Be aware that external processes often store the standard output and standard error streams of the application. This will include logged sensitive information.

Example

The following example code logs user credentials (in this case, their password) in plaintext:

let password = "P@ssw0rd" NSLog("User password changed to \(password)")

Instead, you should encrypt or obfuscate the credentials, or omit them entirely:

let password = "P@ssw0rd" NSLog("User password changed")

References