You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Many Android applications implement their **own “plugin” or “dynamic feature” update channels** instead of using the Google Play Store. When the implementation is insecure an attacker able to intercept the traffic can supply **arbitrary native code that will be loaded inside the app process**, leading to full Remote Code Execution (RCE) on the handset – and in some cases on any external device controlled by the app (cars, IoT, medical devices …).
5
+
Many Android applications implement their own “plugin” or “dynamic feature” update channels instead of using the Google Play Store. When the implementation is insecure an attacker able to intercept or tamper with the update traffic can supply arbitrary native or Dalvik/ART code that will be loaded inside the app process, leading to full Remote Code Execution (RCE) on the handset – and in some cases on any external device controlled by the app (cars, IoT, medical devices …).
6
6
7
-
This page summarises a real‐world vulnerability chain found in the Xtool **AnyScan** automotive-diagnostics app (v4.40.11 → 4.40.40) and generalises the technique so you can audit other Android apps and weaponise the mis-configuration during a red-team engagement.
7
+
This page summarises a real‐world vulnerability chain found in the Xtool AnyScan automotive-diagnostics app (v4.40.11 → 4.40.40) and generalises the technique so you can audit other Android apps and weaponise the mis-configuration during a red-team engagement.
8
+
9
+
---
10
+
## 0. Quick triage: does the app have an in‑app updater?
The response body is an **XML document** whose `<FileData>` nodes contain **Base64-encoded, DES-ECB encrypted** JSON describing every available plugin.
86
+
The response body is an XML document whose `<FileData>` nodes contain Base64-encoded, DES-ECB encrypted JSON describing each available plugin.
41
87
42
88
Typical hunting steps:
43
89
1. Locate the crypto routine (e.g. `RemoteServiceProxy`) and recover:
44
-
* algorithm (DES / AES / RC4 …)
45
-
* mode of operation (ECB / CBC / GCM …)
46
-
* hard-coded key / IV (often 56-bit DES keys or 128-bit AES keys in constants)
90
+
- algorithm (DES / AES / RC4 …)
91
+
- mode of operation (ECB / CBC / GCM …)
92
+
- hard-coded key / IV (commonly 56‑bit DES or 128‑bit AES constants)
47
93
2. Re-implement the function in Python to decrypt / encrypt the metadata:
- Metadata is often JSON-within-XML or protobuf; weak ciphers and static keys are common.
112
+
- Many updaters accept plain HTTP for the actual payload download even if metadata comes over HTTPS.
113
+
- Plugins frequently unzip to app-internal storage; some still use external storage or legacy `requestLegacyExternalStorage`, enabling cross-app tampering.
cd outdex && zip -r plugin.jar classes.dex # the updater will fetch this
161
+
```
162
+
163
+
If the target calls `Class.forName("pwn.Dropper")` your static initializer executes; otherwise, reflectively enumerate loaded classes with Frida and call an exported method.
164
+
165
+
---
85
166
## 4. Deliver the Payload with mitmproxy
86
167
87
-
`addon.py` example that *silently* swaps the original metadata:
168
+
`addon.py` example that silently swaps the original metadata:
// Less surgical (use only if needed): defeat Arrays.equals() for byte[]
209
+
Java.perform(() => {
210
+
constArrays=Java.use('java.util.Arrays');
211
+
Arrays.equals.overload('[B', '[B').implementation=function(a, b) { returntrue; };
212
+
});
213
+
```
114
214
115
-
## 5. Post-Exploitation Ideas
215
+
Also consider stubbing vendor methods such as `PluginVerifier.verifySignature()`, `checkHash()`, or short‑circuiting update gating logic in Java or JNI.
216
+
217
+
---
218
+
## 5. Other attack surfaces in updaters (2023–2025)
219
+
220
+
- Zip Slip path traversal while extracting plugins: malicious entries like `../../../../data/data/<pkg>/files/target` overwrite arbitrary files. Always sanitize entry paths and use allow‑lists.
221
+
- External storage staging: if the app writes the archive to external storage before loading, any other app can tamper with it. Scoped Storage or internal app storage avoids this.
222
+
- Cleartext downloads: metadata over HTTPS but payload over HTTP → straightforward MITM swap.
223
+
- Incomplete signature checks: comparing only a single file hash, not the whole archive; not binding signature to developer key; accepting any RSA key present in the archive.
224
+
- React Native / Web-based OTA content: if native bridges execute JS from OTA without strict signing, arbitrary code execution in the app context is possible (e.g., insecure CodePush-like flows). Ensure detached update signing and strict verification.
225
+
226
+
---
227
+
## 6. Post-Exploitation Ideas
116
228
117
-
* Steal session cookies, OAuth tokens, or JWTs stored by the app.
118
-
* Drop a second-stage APK and silently install it via `pm install`(the app already has`REQUEST_INSTALL_PACKAGES`).
119
-
* Abuse any connected hardware – in the AnyScan scenario you can send arbitrary **OBD-II / CAN bus commands** (unlock doors, disable ABS, etc.).
229
+
- Steal session cookies, OAuth tokens, or JWTs stored by the app.
230
+
- Drop a second-stage APK and silently install it via `pm install`if possible (some apps already declare`REQUEST_INSTALL_PACKAGES`).
231
+
- Abuse any connected hardware – in the AnyScan scenario you can send arbitrary OBD‑II / CAN bus commands (unlock doors, disable ABS, etc.).
120
232
121
233
---
122
234
### Detection & Mitigation Checklist (blue team)
123
235
124
-
* NEVER ship a production build with a custom TrustManager/HostnameVerifier that disables certificate validation.
125
-
* Do not download executable code from outside Google Play. If you *must*, sign each plugin with the same **apkSigning v2** key and verify the signature before loading.
126
-
* Replace weak/hard-coded crypto with **AES-GCM** and a server-side rotating key.
127
-
* Validate the integrity of downloaded archives (signature or at least SHA-256).
236
+
- Avoid dynamic code loading and out‑of‑store updates. Prefer Play‑mediated updates. If dynamic plugins are a hard requirement, design them as data‑only bundles and keep executable code in the base APK.
237
+
- Enforce TLS properly: no custom trust‑all managers; deploy pinning where feasible and a hardened network security config that disallows cleartext traffic.
238
+
- Do not download executable code from outside Google Play. If you must, use detached update signing (e.g., Ed25519/RSA) with a developer‑held key and verify before loading. Bind metadata and payload (length, hash, version) and fail closed.
239
+
- Use modern crypto (AES‑GCM) with per‑message nonces for metadata; remove hard‑coded keys from clients.
240
+
- Validate integrity of downloaded archives: verify a signature that covers every file, or at minimum verify a manifest of SHA‑256 hashes. Reject extra/unknown files.
241
+
- Store downloads in app‑internal storage (or scoped storage on Android 10+) and use file permissions that prevent cross‑app tampering.
242
+
- Defend against Zip Slip: normalize and validate zip entry paths before extraction; reject absolute paths or `..` segments.
243
+
- Consider Play “Code Transparency” to allow you and users to verify that shipped DEX/native code matches what you built (compliments but does not replace APK signing).
128
244
129
245
---
130
246
## References
131
247
132
248
-[NowSecure – Remote Code Execution Discovered in Xtool AnyScan App](https://www.nowsecure.com/blog/2025/07/16/remote-code-execution-discovered-in-xtool-anyscan-app-risks-to-phones-and-vehicles/)
0 commit comments