Android Enterprise Work Profile Required-App Replacement

Tip

Impara e pratica il hacking AWS:HackTricks Training AWS Red Team Expert (ARTE)
Impara e pratica il hacking GCP: HackTricks Training GCP Red Team Expert (GRTE) Impara e pratica il hacking Azure: HackTricks Training Azure Red Team Expert (AzRTE)

Supporta HackTricks

Superficie di attacco

Android Enterprise Work Profiles sono implementati come secondary Android users (esempio BYOD: utente 0 = personale, utente 1 = lavoro). Ogni utente ha alberi /data/user/<id> indipendenti, system apps, istanze di Play Services e oggetti di policy mantenuti dall’MDM. Quando un MDM come Microsoft Intune marca un’app come required per il Work Profile, il Work-Profile Play Store (Finsky) conferma periodicamente che il pacchetto sia presente e lo installa automaticamente se mancante.

Anche dopo la patch CVE-2023-21257 che blocca gli ADB sideloads quando sono impostati DISALLOW_INSTALL_APPS o DISALLOW_DEBUGGING_FEATURES, la seguente catena permette a un attaccante di sostituire qualsiasi app del Work Profile richiesta da Intune con codice arbitrario:

  1. Abusare del percorso di Android Studio “Install for all users” per predisporre un APK malevolo che sembri un aggiornamento del pacchetto gestito.
  2. Far sì che l’MDM rilevi che l’app required è mancante. Intune innesca l’istanza Work-Profile di Finsky per reinstallarla.
  3. Finsky confronta la versione dell’APK staged con quella del Play Store e installa silenziosamente il versionCode più alto, bypassando la restrizione originale.

Ricognizione e controlli preliminari

  • Confermare la disposizione multi-user e gli ID utente:
adb shell pm list users
# Expect user 0 = Owner, user 1 = Work profile (or higher if multiple profiles exist)
  • Le installazioni dirette nell’work user falliscono a causa della policy (errore previsto):
adb install --user 1 legit.apk
# java.lang.SecurityException: Shell does not have permission to access user 1
  • Devi avere accesso fisico temporaneo a un BYOD sbloccato per abilitare Developer Options + USB debugging.
  • Identifica il package name di un’app Work-Profile marcata come required (es. com.workday.workdroidapp).

Sfruttare l’installer multi-utente di Android Studio

La configurazione Run/Debug di Android Studio può ancora installare build con il flag INSTALL_ALL_USERS. Prima di eseguire, abilita Deploy as instant appInstall for all users.

Compila il payload malevolo con lo stesso package name dell’app gestita e un versionCode molto più alto in modo che PackageManager/Finsky lo consideri una release più recente:

android {
namespace = "com.workday.workdroidapp"
defaultConfig {
applicationId = "com.workday.workdroidapp"
versionCode = 900000004
versionName = "9000000004.0"
}
}

Quando Android Studio deploys:

  1. Personal user (0) installs the malicious package normally.
  2. Work Profile user (1) receives the APK in a temporary staging area and tries to treat it as an update.
  3. CVE-2023-21257’s logic sees the user is restricted → install is denied, but the legitimate managed app is marked uninstalled and the staged APK remains cached.

Bypass di auto-installazione Intune/Finsky

Entro ~1–10 minuti (intervallo di refresh delle policy):

  1. Intune/Company Portal detects the required package is missing from the Work Profile.
  2. The Work-Profile Finsky instance is asked to reinstall it.
  3. During version resolution Finsky compares:
  • Play Store metadata for com.workday.workdroidapp.
  • The locally staged APK from the previous install attempt.
  1. Because the local build has the highest versionCode, Finsky trusts it as the most recent release and installs it into the restricted Work Profile without re-applying DISALLOW_INSTALL_APPS / DISALLOW_DEBUGGING_FEATURES checks.

The malicious binary now resides inside the Work Profile under the genuine package name and is considered compliant by the MDM.

Opportunità di post-exploitation

  • Work-profile data access – altre app enterprise continuano a fidarsi di Intents/content providers legati al package sostituito, permettendo furto di dati interni ed esfiltrazione covert dal Work Profile verso l’infrastruttura dell’attaccante.
  • Per-app VPN hijack – se il package sostituito è mappato a un Intune per-app VPN (MS Tunnels + Defender), la build malevola eredita automaticamente il profilo VPN, dando accesso diretto agli host interni da un processo controllato dall’attaccante.
  • Persistence – poiché l’MDM ora crede che l’app richiesta sia installata, esso reinstallerà la build malevola ogni volta che l’utente o il defender la rimuovono, garantendo un foothold a lungo termine sui Work Profile BYOD.

References

Tip

Impara e pratica il hacking AWS:HackTricks Training AWS Red Team Expert (ARTE)
Impara e pratica il hacking GCP: HackTricks Training GCP Red Team Expert (GRTE) Impara e pratica il hacking Azure: HackTricks Training Azure Red Team Expert (AzRTE)

Supporta HackTricks