From Intent to Native Code: Exploiting a WebView’s JavascriptInterface via XSS
The WebView activity passed an untrusted Intent extra into a JavaScript function that inserted it into the page using innerHTML, creating a DOM-based XSS. An attacker could inject an event handler that called the exposed JavascriptInterface, leading to native code execution.
Published on medium.com
Hi, I’m Mohamed — a security researcher and bug bounty hunter and with a passion for uncovering real-world vulnerabilities that often go unnoticed. I’ve been acknowledged by organizations like NASA, the U.S.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Impact
An attacker could execute arbitrary JavaScript in the WebView and call the exposed native method, potentially leading to further actions such as launching an activity with a secret.
What the attacker needed
Ability to start the activity with a crafted Intent extra
How it was found
- The activity reads the NAME string extra from the Intent.
- After the page loads, it calls initApp with a JSON object containing the NAME value.
- initApp sets innerHTML using a template string that includes obj.name.
- The injected img tag with an invalid src triggers the onerror handler.
- The onerror handler calls window.hextree.success(), which invokes the native success method.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A WebView is a mini browser inside an Android app. The app took a name from another app and put it straight into the page's HTML without cleaning it, so a crafted name could run JavaScript. That JavaScript could then call a special bridge the app had exposed, which ran native Android code.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.