Rule Definition
To save a password or any other type of sensitive information in an iOS app, you have to use the iOS Keychain. This is Appleās way of storing things securely for you.
Remediation
Prefer using designation like kSecAttrAccessibleWhenUnlocked, or kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly, etc...
Violation Code Sample
var query: [String: Any] = [kSecClass as String: kSecClassInternetPassword,
kSecAttrAccount as String: account,
kSecAttrServer as String: server,
kSecValueData as String: password,
kSecAttrAccessible as String: kSecAttrAccessibleAlways]
SecItemAdd(query,r)
Fixed Code Sample
var query: [String: Any] = [kSecClass as String: kSecClassInternetPassword,
kSecAttrAccount as String: account,
kSecAttrServer as String: server,
kSecValueData as String: password,
kSecAttrAccessible as String: kSecAttrAccessibleWhenUnlocked]
SecItemAdd(query,r)
Reference
https://developer.apple.com/security/
Related Technologies
Technical Criterion
Secure Coding - API Abuse
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.