arbisoft brand logo
arbisoft brand logo
Contact Us

Securing Mobile Applications: Best Practices for iOS and Android Developers - Part 4

Muhammad's profile picture
Muhammad Mohsin RazaPosted on
7 Min Read Time
https://d1foa0aaimjyw4.cloudfront.net/Blog_4_AWC_Blog_Series_Securing_Mobile_Applications_9c462b6f19.jpg

In the previous part of this blog series, we discussed best practices for securing mobile applications, focusing on authentication and session management. Now, we shift our attention to another essential layer of mobile security, platform interaction requirements. These security measures ensure that mobile apps interact with platform APIs and system components securely, minimizing risks related to excessive permissions, unvalidated inputs, JavaScript execution, and overlay attacks.

 

Platform Interaction Requirements

The security measures in this group ensure that the app uses platform APIs and standard components securely.

The App Only Requests the Minimum Permissions Necessary

The mobile app should follow the principle of least privilege and request only the minimum permissions needed to function properly. This limits access to sensitive data and system resources. In case of a security breach, the potential impact is significantly reduced.

 

Scenario
A mobile app requests multiple permissions, such as location, contacts, camera, storage, and gallery, but it only needs camera and storage permissions to function properly.

 

Attack
If compromised, mobile apps with excessive permissions (camera, gallery, storage, location, contacts) can be exploited. Once granted, permissions can be misused to collect sensitive data or install malicious software. Also, prompting users to grant too many permissions can raise concerns.

 

Mitigation
The app should request only essential permissions, such as camera and storage, for its core functionality. Users should be assured that their sensitive data, like location or contacts, is not accessed unnecessarily. The app should also comply with privacy laws and best practices for responsible data handling.

 

All Inputs from External Sources and Users Are Validated and Sanitized If Necessary

Inputs from external sources (clients) should be thoroughly validated and sanitized before being stored to prevent malicious data from compromising the app’s security. This includes any data received from the UI or through inter-process communication (IPC) mechanisms like intents, custom URLs, or network sources.

 

Scenario
The app accepts user input for a search field and processes data from external sources, such as custom URLs or network APIs, without validation or sanitization.

 

Attack
The mobile app has a user input field and data is stored without any validation. An attacker can enter a malicious query in search fields like DROP TABLE users, if this query is sent through a search field will cause SQL Injection attacks and will lead to database manipulation. Also, injected scripts in inputs can execute malicious actions when displayed on the UI.

 

Mitigation
Inputs from external sources (clients) should be thoroughly validated and sanitized, By ensuring that inputs are clean and properly validated before processing, the app mitigates the risk of injection attacks, and cross-site scripting (XSS). In addition, other vulnerabilities could be exploited to harm the system or user data as well.

 

JavaScript Is Disabled in WebViews Unless Explicitly Required

If a mobile app uses embedded WebViews, JavaScript should be disabled unless required for specific functionality. Disabling JavaScript in WebViews reduces the attack surface by preventing harmful scripts from executing, which can lead to cross-site scripting (XSS) attacks. If JavaScript must be enabled for certain features, strict controls should be implemented to minimize risks.

 

Scenario
A mobile app includes embedded WebViews to display content, but JavaScript is not disabled.

 

Attack
Such mobile apps are vulnerable to cross-site scripting (XSS). Malicious JavaScript can be injected through untrusted websites, allowing attackers to steal cookies and session tokens. It can also perform malicious actions on behalf of the user. Malicious scripts may even create fake login forms, leading to phishing attacks.

 

Mitigation
JavaScript should be disabled by default in WebViews. If enabling JavaScript is necessary, strict controls should be in place to monitor which scripts can run and what resources they can access.

 

The App Protects Itself Against Screen Overlay Attacks (Android Only)

Screen overlay attacks are common on Android devices, so apps should include protective measures. These attacks occur when a malicious app creates a transparent layer over the app’s UI, tricking the user into interacting with it.

 

Scenario
An Android app does not implement any mechanism to protect against screen overlay attacks, such as clicking on buttons or providing sensitive information.

 

Attack
A malicious app places a transparent layer over the UI, causing the user to interact with it unintentionally.

 

Mitigation
To prevent screen overlay attacks, apps should monitor and restrict the use of screen overlay permissions. If overlay permissions are detected, the app should prompt the user to disable them for other apps. Sensitive UI elements should be designed to prevent overlays from interfering, using system-level checks or specific drawing flags.

 

Conclusion

Keeping mobile apps secure is important for protecting user data and privacy. Developers can improve security by asking for only the necessary permissions, checking and cleaning user inputs, turning off JavaScript in WebViews unless needed, and blocking screen overlay attacks. These steps help prevent hackers from misusing the app and make users feel safe. Since security risks keep changing, developers should regularly update their apps, test for weaknesses, and stay informed about new threats to keep their apps safe.

...Loading

Explore More

Have Questions? Let's Talk.

We have got the answers to your questions.

Newsletter

Join us to stay connected with the global trends and technologies