JS Bridge Callback-ID Injection
← Native / WebView Bridge (JS <-> Native)
js_bridge_callback_id_injection HARD
| Category | Native / WebView Bridge (JS <-> Native) |
| OWASP Mobile (2024) | M4 |
| MASVS | MASVS-PLATFORM-2MASVS-CODE-4 |
| MASWE | MASWE-0033 |
| MASTG (v2 tests) | iOSNone publishedAndroidMASTG-TEST-0334 |
| MASTG demos | iOSNone publishedAndroidMASTG-DEMO-0097 |
| CWE | CWE-345CWE-441CWE-20 |
| Platform | AndroidiOS |
Description
The native bridge trusts a caller-supplied callbackId and dispatches the result to it without validation, so web content forges an id to invoke a native callback belonging to another (privileged) plugin - Camera/Contacts/Files/Geolocation (Cordova InAppBrowser iOS CVE-2026-47430 class).
How it works
A Cordova-style native bridge lets each JS plugin register a native callback keyed by a caller-supplied callbackId. When a plugin resolves, the native side dispatches the result to whatever callbackId the web message names, without verifying the id belongs to the requesting plugin. So attacker JS running as the unprivileged Console plugin forges the privileged Camera plugin’s callbackId and receives the Camera result (a photo URI and bytes) into its own handler (Cordova InAppBrowser iOS CVE-2026-47430 class). This runs in a real WebView: the page forges the Camera callbackId over a native JS channel and the native side delivers the Camera result into the attacker’s handler (the in-memory panels are the offline contrast). The secure path validates the callbackId format with a strict regex and checks that the id was registered by the requesting plugin, so the forged id is refused.
How to exercise it. DVMA is the harness - open this module from the home index and tap the demo action. The screen ships the malicious input and simulates the attacker (e.g. the companion app, crafted intent, or scanned payload) in-process, and the evidence panel prints the proof. The Tools (optional) and Attack inputs below are only needed to reproduce the exploit end-to-end on a real device.
Exploit steps
- Set up. Build DVMA with a flavor that enables the Native / WebView Bridge (JS <-> Native) category (e.g.
--dart-define-from-file=config/flavors/dev.json) and run on an emulator/simulator you control. The demo needs no external tooling; for the optional on-device reproduction the relevant tools are:r2frida,objection,frida,mitmproxy· Android:jadx· iOS:ipsw,class-dump,Hopper. - Locate the target. From the home index, open JS Bridge Callback-ID Injection (
js_bridge_callback_id_injection). The How it works section above describes this module’s specific weakness; the screen states the intended-secure behavior and exposes the vulnerable action. - Exploit. Reach the JS<->native bridge (or the framework/plugin API) from untrusted web content / a cross-origin iframe / a malicious provider, and confirm the privileged native call fires with no main-frame/origin, callback-id, or permission gate in between.
- Observe the evidence. Trigger the vulnerable action and read the evidence panel - it prints the concrete proof (leaked value, accepted replay, executed payload, or unauthorized result).
- Contrast with the secure path. Run the module’s secure/hardened action (where provided) and confirm the same attack is rejected - this is what a correct implementation should do.
- Map it back. Cross-reference the MASTG v2 test(s) MASTG-TEST-0334 for the canonical procedure and remediation.
Tools (optional)
Android
iOS
Real-world references
Concrete public disclosures that match this vulnerability class: