iOS Sensitive data stored in keyboard cache
iOS 键盘缓存中存储的敏感数据
描述
iOS 会将几乎所有非数字单词存储在键盘缓存中。如果不禁用自动纠错功能,登录凭据或密码等敏感信息可能会被泄露。
建议
键盘缓存是由 UITextField、UITextView 和 UISearchBar 支持的 UITextInputTraits 协议引起的。
为防止键盘缓存泄露敏感字段的输入,请考虑以下措施:
autocorrectionType决定在输入期间是否启用自动纠错。此属性的默认值为UITextAutocorrectionTypeDefault,对于大多数输入法而言,这将启用自动纠错。
let textField = UITextField(frame: CGRect(x: 0, y: 0, width: 200, height: 40))
textField.autocorrectionType = .no // Disable autocorrection
isSecureTextEntry决定是否禁用文本复制和缓存,并为UITextField隐藏正在输入的文本。此属性的默认值为NO。
let textField = UITextField(frame: CGRect(x: 0, y: 0, width: 200, height: 40))
textField.isSecureTextEntry = true // Enable secure text entry
链接
- CWE-200: Exposure of Sensitive Information to an Unauthorized Actor
- OWASP: Finding Sensitive Data in Keyboard Cache
标准
- OWASP_MASVS_L1:
- MSTG_STORAGE_5
- OWASP_MASVS_L2:
- MSTG_STORAGE_5
- PCI_STANDARDS:
- REQ_2_2
- REQ_3_2
- REQ_3_3
- REQ_3_5
- REQ_6_2
- OWASP_MASVS_v2_1:
- MASVS_STORAGE_1
- MASVS_STORAGE_2
- HIPAA_CONTROLS:
- SECURITY251
- SECURITY212
- SECURITY213