Why it matters

A WebView with JavaScript bridges runs web content next to native code. If it loads content the app does not control, or accepts bridge messages from any frame, a cross-site scripting bug becomes access to native features and stored data.

How to meet it

  • Load only content you control, and turn off JavaScript and file access when the page does not need them.
  • Expose the smallest bridge API, and act only on messages from the expected origin and main frame.
  • Restrict navigation to approved domains, with app-bound domains on iOS and WebViewAssetLoader for local content on Android.

MASTG tests in the local projects

The local projects run these OWASP MASTG v2.0.0 tests for MASVS-PLATFORM-2, as tests you can repeat on your own machine.

MASTG testPlatformProject
MASTG-TEST-0376: References to Native Bridge APIs in WebViewsiOSKeep an iOS app's storage, links and web bridge in bounds · WebBridgeTests

Guides on this site

Practice

References

  1. MASVS-PLATFORM-2 (OWASP MASVS v2.1.0)
  2. MASVS-PLATFORM: Platform Interaction (OWASP MASVS v2.1.0)

List data from the publisher. A guide is listed as the main subject when the weakness or risk is what the guide is about, and as covering it when a dedicated section or worked example addresses it.

Control statements are quoted from OWASP MASVS v2.1.0, licensed CC BY-SA 4.0; the rest is this site's summary. MASTG tests are those the iOS and Android projects here run, with their titles from mas.owasp.org. License.