Rule Definition
Insecure data storage vulnerabilities occur when development teams assume that users or malware will not have access to a mobile device's filesystem and subsequent sensitive information in data-stores on the device or are cloud synced.
Remediation
Other possible values are:
- URLCredential.Persistence.none: Credential should not be stored.
- URLCredentialPersistence.forSession: Credential should be stored only for this session.
- URLCredentialPersistence.permanent: Credential should be stored in the Keychain.
Violation Code Sample
let credential = URLCredential.init(user: user, password: password, persistence: URLCredential.Persistence.synchronizable)
let shared = URLCredentialStorage.shared
let protectionSpace = URLProtectionSpace.init()
shared.setDefaultCredential(credential, for: protectionSpace)
Fixed Code Sample
let credential = URLCredential.init(user: user, password: password, persistence: URLCredential.Persistence.none)
let shared = URLCredentialStorage.shared
let protectionSpace = URLProtectionSpace.init()
shared.setDefaultCredential(credential, for: protectionSpace)
Reference
https://www.owasp.org/index.php/Mobile_Top_10_2016-M2-Insecure_Data_Storage
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.