medium · M4 · MASVS-PLATFORM-2 · PTKD-WEBVIEW-JSI
WebView JavaScript bridge exposed
A JavaScript bridge (Android addJavascriptInterface, iOS WKScriptMessageHandler) exposes native code to the pages a WebView shows; on old Android WebViews it enables remote code execution.
How it is exploited
addJavascriptInterface exposes native methods to page JavaScript. If the WebView ever renders attacker-influenced content (http page, MITM, open redirect, ad), that script calls your bridge directly; pre-API-21 it was full RCE.
Why it matters
Web content escalates into native capability: file access, token theft, or arbitrary actions your bridge allows.
How to fix it
- Only attach the bridge to WebViews that load exclusively your own HTTPS origins; verify with shouldOverrideUrlLoading.
- Annotate the minimal method set with @JavascriptInterface and treat every argument as hostile input.
- Prefer WebMessageListener/postMessage channels with origin allowlists on modern AndroidX WebKit.
Does your app have this?
PTKD checks your build or your source project for PTKD-WEBVIEW-JSI and every other check in this knowledge base.
Scan your appReferences
Related checks (M4)
- Supabase function runs any SQL the caller sends
- Deep link URL loaded or opened without a host check (heuristic)
- Hybrid WebView may open any website inside the app
- Wildcard associated domain (universal-link hijack surface)
- Process execution via system()/exec/popen
- Unsafe C string function (buffer overflow risk)
- Hijackable custom URL-scheme deep link
- SQL built by joining request data into a string (text search)