GHSL-2023-142: Arbitrary URL loading in a WebView in Home Assistant Android Companion - CVE-2023-41898
The Home Assistant Android app has an exported activity that loads an arbitrary URL into a JavaScript-enabled WebView. A malicious app on the same device could send an Intent to this activity, leading to JavaScript execution, limited native code execution, and theft of the user's authentication token.
Originally disclosed on GitHub Security Lab
The Home Assistant Companion for Android app up to version 2023.6.0 is vulnerable to arbitrary URL loading in a WebView. This enables all sorts of attacks, including arbitrary JavaScript execution, limited native code execution, and credential theft.
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 report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the exported activity accepted an arbitrary URL from an Intent and loaded it into a WebView without validation, and a second WebView activity also allowed JavaScript injection via the path parameter.
Impact
This issue may lead to arbitrary JavaScript code execution in a WebView, limited native code execution, and credential theft.
What the attacker needed
Malicious app on same device; Home Assistant app installed
The fix
The vulnerability was fixed in version 2023.9.2 of the app.
How it was found
- A malicious app on the same device sends an Intent to the exported MyActivity with a URL pointing to an attacker-controlled site.
- The MyActivity loads that URL in a WebView with JavaScript enabled.
- The attacker's site executes JavaScript that redirects to a homeassistant://navigate/ URL containing a crafted path.
- The WebViewActivity receives the path and either loads an arbitrary URL or injects JavaScript via the entityId parameter.
- The injected JavaScript calls the getExternalAuth JavaScript interface with a malicious callback to exfiltrate the authentication token.
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.
An exported activity in an Android app can be started by any other app on the phone. Here, that activity loaded whatever web address it was given into a browser view that runs JavaScript. A malicious app could use this to run its own code and steal the user's login token for Home Assistant.
What is Mobile?
Flaws specific to Android and iOS apps: exported components, deep links, WebViews and data left on the device.