The OWASP Mobile Top 10 provides a comprehensive summary of the ten most crucial security threats faced by your mobile applications, applicable to both Android and iOS platforms. These top 10 risks encompass various attack scenarios, offering insights into what to anticipate and how to safeguard against them.
M1: Improper Credential Usage
Threat actors exploiting hardcoded credentials and improper handling of credentials within mobile applications may employ automated techniques using readily available tools or custom-built ones. These actors could potentially discover and exploit hardcoded credentials or take advantage of weaknesses stemming from the improper use of credentials.
Adversaries have the capability to exploit vulnerabilities in both hardcoded credentials and the mishandling of credentials. Once these vulnerabilities are identified, an attacker can utilize hardcoded credentials to gain unauthorized access to sensitive features of the mobile app. They can also abuse credentials, for example, by gaining entry through improperly validated or stored credentials, thus circumventing the need for legitimate access.
How Can I Prevent ‘Improper Credential Usage’?
Preventing insecure credential management involves refraining from using hardcoded credentials and ensuring proper handling of user credentials.
Avoid the Use of Hardcoded Credentials
Hardcoded credentials can be easily uncovered by attackers, serving as a straightforward entry point for unauthorized users. It is imperative to abstain from incorporating hardcoded credentials within your mobile app’s code or configuration files.
Handle User Credentials Securely
User credentials should always be handled with the utmost security in mind:
- Encrypt credentials during transmission.
- Do not retain user credentials on the device. Consider employing secure, revocable access tokens instead.
- Implement robust user authentication protocols.
- Regularly refresh and rotate any employed API keys or tokens.
M2: Inadequate Supply Chain Security
How To Prevent ‘Inadequate Supply Chain Vulnerability’
- Incorporate secure coding practices, conduct code reviews, and perform testing at various stages of the mobile app development process to identify and address vulnerabilities.
- Ensure a secure app signing and distribution process to thwart attackers from signing and distributing malicious code.
- Utilize only trusted and validated third-party libraries or components to minimize vulnerability risks.
- Establish security controls for app updates, patches, and releases to prevent attackers from exploiting vulnerabilities within the app.
- Implement monitoring and detection measures for supply chain security incidents, employing security testing, scanning, or other techniques to promptly detect and respond to incidents.
M3: Insecure Authentication/Authorization
How To Prevent ‘Insecure Authentication/Authorization’
Avoid Weak Patterns in Authentication:
- Ensure that mobile application authentication requirements match those of the web application component when porting a web application to a mobile platform.
- Be cautious of local user authentication, as it can lead to client-side bypass vulnerabilities, especially on jailbroken devices.
- Conduct authentication requests server-side whenever possible to ensure data availability only after successful authentication.
- If client-side data storage is necessary, encrypt the data using a key derived from the user’s login credentials.
- Do not store a user’s password on the device for the “Remember Me” functionality.
- Use a device-specific authentication token that can be revoked by the user within the mobile application.
- Avoid using easily spoofed values for user authentication, such as device identifiers or geo-location.
- Implement persistent authentication in mobile applications as an opt-in feature, not enabled by default, and discourage users from using 4-digit PIN numbers for authentication.
Reinforce Authentication:
- Developers should assume that all client-side authorization and authentication controls can be bypassed, necessitating strong server-side reinforcement.
- For offline usage, implement local integrity checks in mobile apps to detect unauthorized code changes.
Use FaceID and TouchID:
- Utilize FaceID and TouchID for biometric authentication to securely protect sensitive authentication materials like session tokens.
Insecure Authorization Prevention:
- Backend systems should independently verify roles and permissions of authenticated users without relying solely on information from the mobile device.
- Assume that all client-side authorization can be bypassed, emphasizing strong server-side authorization controls.
- If offline authorization checks are necessary within the mobile app’s code, perform local integrity checks to detect unauthorized code changes.
M4: Insufficient Input/Output Validation
How to Prevent ‘Insufficient Input/Output Validation’:
Input Validation:
- Apply rigorous validation techniques to validate and sanitize user input.
- Enforce input length restrictions and reject unexpected or malicious data.
Output Sanitization:
- Properly sanitize output data to thwart cross-site scripting (XSS) attacks.
- Use output encoding techniques when displaying or transmitting data.
- Conduct specific validation based on data context (e.g., file uploads, database queries) to prevent attacks like path traversal or injection.
- Implement data integrity checks to identify and prevent data corruption or unauthorized modifications.
- Adhere to secure coding practices, such as using parameterized queries and prepared statements, to thwart SQL injection.
- Carry out routine security assessments, including penetration testing and code reviews, to uncover and rectify vulnerabilities.
M5: Insecure Communication
- An adversary who shares your local network (which may be compromised or under surveillance).
- Rogue carrier or network devices (such as routers, cell towers, proxies, etc.).
- Malware present on your mobile device.
- The use of outdated protocols and/or improper configuration settings.
- Acceptance of insecure SSL certificates (such as self-signed, revoked, expired, or those with incorrect hosts).
- Inconsistencies, such as applying SSL/TLS only to specific workflows, such as authentication.
How To Prevent ‘Insecure Communication’?
- Assume network layer is insecure and vulnerable to eavesdropping.
- Implement SSL/TLS on transport channels for data transmission to backend APIs or web services.
- Use SSL versions of third-party entities like analytics companies and social networks when the application interacts with them via browser/webkit to avoid mixed SSL sessions.
- Employ strong, industry-standard cipher suites with appropriate key lengths.
- Utilize certificates from trusted Certificate Authority (CA) providers and never allow bad certificates (self-signed, expired, untrusted root, revoked, wrong host).
- Consider implementing certificate pinning and ensure SSL chain verification. Additionally, verify the identity of the endpoint server using trusted certificates in the key chain before establishing a secure connection.
M6: Inadequate Privacy Controls
- Assume the identity of the victim for fraudulent activities,
- Exploit the victim’s payment information,
- Blackmail the victim using sensitive data, or
- Inflict harm by tampering with or destroying critical victim data.
How To Prevent ‘Inadequate Privacy Controls’?
To prevent privacy breaches, it’s crucial to minimize the volume and diversity of Personally Identifiable Information (PII) being processed. This necessitates a comprehensive understanding of all PII assets within a given application. Armed with this knowledge, consider the following inquiries:
- Is all processed PII truly indispensable, like names, addresses, gender, and age?
- Can some of the PII be substituted with less sensitive information, such as replacing precise location with a broader one?
- Is it possible to scale down certain PII elements, like reducing location updates from every minute to every hour?
- Can some of the PII be anonymized or obscured, for instance, through techniques like hashing, grouping, or adding random data?
- Is it feasible to erase certain PII after a designated period, like retaining only health data from the past week?
- Can users provide consent for optional PII usage, allowing them to receive enhanced services while being informed of the associated additional risk?
M7: Insufficient Binary Protection
How To Prevent ‘Insufficient Binary Protection’?
M8: Security Misconfiguration
How To Prevent Security Misconfigurations?
- Ensure Secure Default Configurations: Verify that initial settings and configurations are adequately protected and do not expose sensitive information or grant unnecessary permissions.
- Avoid Default Credentials: Steer clear of using hardcoded default login credentials.
- Address Insecure Permissions: Do not store application files with excessively permissive permissions, such as making them world-readable or world-writable.
- Apply the Principle of Least Privilege: Request only the permissions essential for the proper operation of the application.
- Implement Secure Network Configuration: Prohibit unencrypted communication and utilize certificate pinning whenever feasible.
- Deactivate Debugging: In the production version of the app, deactivate debugging features.
- Turn off Backup Mode (Android): Disabling backup mode on Android devices prevents the inclusion of app data in the device’s backup, ensuring that sensitive information is not stored in the backup.
- Restrict Application Attack Surface: Only export activities, content providers, and services that are necessary for operation in order to minimize potential points of vulnerability.
M9: Insecure Data Storage
How To Prevent ‘Insecure Data Storage’?
- To safeguard against insecure data storage in a mobile application and ensure the security of sensitive information, it is recommended to enact the following security measures:
- Employ Robust Encryption: Utilize strong encryption algorithms and best practices to safeguard sensitive data both when stored and during transit. Employ widely recognized encryption algorithms and ensure secure storage and management of encryption keys.
- Ensure Secure Data Transmission: Use secure communication protocols (e.g., HTTPS, SSL/TLS) to protect data while it is being transmitted between the mobile application and backend servers. Avoid sending sensitive data through unsecured channels.
- Implement Secure Storage Methods: Store sensitive data in secure locations that are inaccessible to unauthorized users. Leverage platform-specific secure storage mechanisms provided by the mobile operating system, such as Keychain (iOS) or Keystore (Android).
- Enforce Proper Access Controls: Establish stringent access controls to limit unauthorized access to sensitive data. Authenticate users securely, apply role-based access controls, and validate user permissions prior to granting access to sensitive information.
- Validate Input and Sanitize Data: Employ input validation and data sanitization techniques to prevent injection attacks and ensure that only valid and expected data is stored. Validate user inputs to mitigate the risk of malicious code injection or inadvertent data exposure.
- Implement Secure Session Management: Adopt secure session management practices, including the use of randomly generated session tokens, setting appropriate session timeouts, and securely storing session data on both the client and server sides.
- Regularly Update and Patch Dependencies: Keep all libraries, frameworks, and third-party dependencies current, as they may harbor security vulnerabilities that could lead to insecure data storage. Routinely apply security patches and updates provided by the respective vendors.
- Stay Informed: Stay abreast of the latest security threats and vulnerabilities within the mobile application landscape. Monitor security forums, review security advisories, and stay updated on mobile platform developments to promptly address emerging risks.
M10: Insufficient Cryptography
How To Prevent ‘Insufficient Cryptography’?
- Opt for Strong Encryption Algorithms: Choose established and secure encryption methods like AES, RSA, or ECC. Avoid outdated or weak algorithms.
- Ensure Robust Key Length: Select encryption keys with sufficient length to ensure strong security, following industry recommendations for the specific algorithm.
- Secure Key Management: Safeguard encryption keys using methods like key vaults or hardware security modules. Restrict access to authorized personnel and encrypt keys at rest.
- Implement Encryption Correctly: Follow established cryptographic libraries and frameworks for encryption processes. Avoid custom implementations which can be more error-prone.
- Protect Storage of Encryption Keys: Store encryption keys securely on the mobile device, avoiding plain text or easily accessible locations. Consider using secure storage provided by the operating system or hardware-based options.
- Utilize Secure Transport Layer: Employ HTTPS for transmitting encrypted data. Ensure thorough certificate validation and secure communication channels between the mobile app and backend systems.
- Regularly Update and Test Security Measures: Stay informed about security updates and conduct thorough testing, including assessments for cryptographic vulnerabilities, penetration testing, and code reviews. Address any identified weaknesses promptly.