Insecure WebView Configuration

The app's WebViews are configured so that web content they load can reach native app functions or local files, or can load untrusted pages.

SeverityMedium
CVSS 3.15.9 CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:L/A:N Open in the calculator
CVSS 4.05.9 CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:A/VC:H/VI:L/VA:N/SC:N/SI:N/SA:N Open in the calculator
CWECWE-749: Exposed Dangerous Method or Function
OWASP Top 10A01:2025 Broken Access Control
CategoryInput Validation

Description

WebViews display web content inside the app, and their settings decide what that content can do. The weakness arises when a WebView that can load content an attacker influences, such as pages over HTTP, arbitrary URLs passed in intents or deep links, or third-party content, is also given powers beyond those of a normal browser tab. Script running in such a WebView, whether it arrives through a vulnerable page, a manipulated deep link or intercepted traffic, can call the native methods exposed to it, read the app's local files or the user's session tokens, and present convincing phishing content inside the trusted app; depending on what is exposed, this can lead to account compromise or actions performed as the user.

On Android, the risky settings include JavaScript bridges added with addJavascriptInterface, which expose app methods to every script in the page; setAllowFileAccess, setAllowFileAccessFromFileURLs and setAllowUniversalAccessFromFileURLs, which let pages read local files; and URL handlers such as shouldOverrideUrlLoading that load any URL they are given. On iOS, the equivalents are script message handlers registered on a WKWebView, broad file access granted through loadFileURL, and the deprecated UIWebView. Passing session tokens into pages through URLs or JavaScript widens the exposure.

The attacker needs a way to get content into the WebView, which usually requires user interaction or a position on the network. Testing reviews the WebView configuration in code, checks whether attacker-controlled content can be loaded, for example through a deep link or by intercepting HTTP traffic, and then establishes what that content can reach.

Remediation

  • Load only the organisation's own content over HTTPS in WebViews that have bridges or file access, validate URLs against an allowlist of hosts before loading them, and open other links in the system browser.
  • Expose as few native methods as possible through JavaScript bridges, check the origin of each call, and never expose methods that return tokens or perform sensitive actions without confirmation.
  • Disable JavaScript where it is not needed, and disable file access with setAllowFileAccess(false), leaving the file URL access settings off; serve local content through WebViewAssetLoader instead.
  • On iOS, use WKWebView, limit the read access given to loadFileURL to the specific directory needed, and check the frame's origin in script message handlers.

Confirm the fix by attempting to load attacker-controlled content into each WebView and checking that it is refused or cannot reach native methods or files.

References


Add This Finding to Your Library

In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.

Free trial  ·  No card required

Only need the reporting? Our reporting tool is free and open source, with the same library.


More Mobile Applications Findings

Every Mobile Applications finding