The Silent Token Leak: The Hidden Danger of WebView.loadUrl() in Android
The Android app passed the user's JWT in the Authorization header to WebView.loadUrl() without validating the destination URL. An attacker who can control the URL (e.g., via a deep link) could receive the token and take over the account.
Published on medium.com
In the era of hybrid mobile applications, developers often rely on WebView to seamlessly integrate web-based features within native Android environments. To ensure a smooth user experience, maintaining the session across the native app and the web view is crucial.
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
Root cause
The app attached sensitive authentication headers to WebView requests without checking that the destination host was trusted.
Impact
If chained with an exported activity that accepts unvalidated URLs, an attacker could steal the victim's JWT and achieve account takeover with a single click.
What the attacker needed
Attacker can control the URL loaded in WebView; victim clicks a malicious deep link
The fix
The app should validate the destination host against a strict allowlist before attaching sensitive headers, or use Custom Tabs instead of a custom WebView.
How it was found
- Intercept the app at runtime and modify the target URL to point to an attacker-controlled server.
- Observe that the WebView sends the request with the Authorization header to the attacker's server.
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 app. The app attached the user's login token (like a password) to every request it made in that browser, even to websites the attacker controlled. If the attacker can make the app open their website, they steal the token and log in as the user.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.