Untrusted content loaded inside mobile WebViews
WebView navigation must retain the trust assumptions of the native app around it. Understanding untrusted content loaded inside mobile webviews helps establish which security property the feature needs and where that property is actually enforced.
What does this involve?
Browser security is influenced by origins, embedded content, messaging and the way returned data is interpreted. A server can make a correct decision while client-side code later exposes the result to an unintended page or execution context.
Note that using a WebViewClient is not inherently insecure. The test fails only when the URL handling logic does not properly restrict navigation to trusted content.
Apps can also disable SafeBrowsing at runtime by calling WebSettings.setSafeBrowsingEnabled(false) on a WebView instance. This takes precedence over the manifest setting, so even if the manifest enables SafeBrowsing, it can still be disabled in code.
Why it matters
Consider a realistic failure: a redirect moves a privileged embedded browser from a trusted page to attacker-controlled content.
A browser trust failure can affect signed-in users, private responses or actions taken with a user's session. The assessment should identify the relevant browser behaviour and the server-side permissions that remain in force.
Mobile behaviour can change between a fresh installation, an authenticated session, background activity and a device migration. The assessment needs the actual release and representative supported device states.
How penetration testers check for it
Test navigation, redirects, mixed content and custom URL handling.
- shouldOverrideUrlLoading: allows the application to either abort loading WebViews with suspicious content by returning true or allow the WebView to load the URL by returning false. Note that this method is not called for POST requests, XmlHttpRequests, iFrames, "src" attributes in HTML, or tags.
- shouldInterceptRequest: allows the application to return custom data from resource requests. This callback is invoked for various URL schemes (e.g., http(s):, data:, file:), but not for javascript: or blob: URLs, or for assets accessed via file:///android_asset/ or file:///android_res/.
- No validation: the method does not check the URL against an allowlist or denylist before allowing navigation or returning resource data.
- Weak validation: the method performs validation that does not reliably prevent navigation to untrusted domains (for example, substring checks instead of validating the host).
- Trace untrusted data into rendering and navigation.
- Check credentialed requests and sensitive state changes.
How to fix it
Restrict trusted navigation and open unrelated destinations outside privileged application contexts.
- Keep trusted and untrusted content in appropriate contexts.
- Use safe rendering and precisely scoped browser policies.
- Validate messaging origins and intended recipients.
- Retain independent server-side identity and permission checks.
A policy finding needs application context. The absence of a particular header or browser feature is not, by itself, proof that protected data can be accessed.
Recheck the changed behaviour against the original failure conditions and the legitimate user journey. Keep enough evidence to show which release and configuration were verified, and include related entry points that depend on the same security decision.
Related issues
- WebViews that combine local resources with untrusted content
- Assessing mobile app behaviour inside cloned environments
- Protecting sensitive resources inside mobile packages
Read about our methodology or contact pentested.com to discuss your mobile applications.