敏感信息明文记录¶
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
攻击者可以访问未加密记录的敏感信息。
建议¶
在记录敏感信息之前,始终确保将其加密或混淆。
通常,您应该仅在需要以明文使用敏感信息时将其解密。
请注意,外部进程通常会存储应用程序的标准输出和标准错误流。这将包括记录的敏感信息。
示例¶
以下示例代码以明文形式记录用户凭据(在本例中为其密码)
let password = "P@ssw0rd"
NSLog("User password changed to \(password)")
相反,您应该加密或混淆凭据,或完全省略它们
let password = "P@ssw0rd"
NSLog("User password changed")