Mobile malware that reaches a command interpreter can run arbitrary commands, scripts and binaries, and with root or a jailbreak it can change protected system files. MITRE ATT&CK for Mobile tracks this as T1623 Command and Scripting Interpreter, under the Execution tactic, with one sub-technique, T1623.001 Unix Shell. ATT&CK lists both Android and iOS. This guide explains how the technique differs on each platform, what real malware has done with it, and how app vetting, MDM compliance, attestation and forensics expose it. It is for mobile security engineers, SOC analysts and incident responders. For the wider matrix, see the MITRE ATT&CK for Mobile Guide.
Key takeaways
- Both platforms, different exposure. Android is UNIX-like and exposes a shell through Android Debug Bridge (ADB) or Java's
Runtimepackage; on stock iOS, ATT&CK's detection guidance treats any shell spawn as a jailbreak indicator. - Root changes the stakes. ATT&CK notes some shell commands need elevated privileges available only on rooted or jailbroken devices, where malware may invoke a superuser binary.
- Interpreters are not only shells. ATT&CK records TianySpy stealing data with malicious JavaScript and NGate using Java to load and verify runtime configuration.
- Detection lives in vetting and compliance. Watch for apps that call
Runtime.exec()orProcessBuilder.start()withsh,toyboxorsu, and for rooted or jailbroken devices. - Two mitigations. ATT&CK lists M1002 Attestation and M1010 Deploy Compromised Device Detection Method, because both can detect jailbroken or rooted devices.
What T1623 is
ATT&CK describes the technique as abusing command and script interpreters to execute commands, scripts or binaries. Commands can be embedded in initial access payloads, delivered as second-stage payloads from C2, or run through interactive shells. The enterprise equivalent is T1059, covered in the T1059 Command and Scripting Interpreter Defensive Guide; this page covers the mobile differences only.
Android and iOS compared
| Aspect | Android | iOS |
|---|---|---|
| Shell access for apps | ATT&CK: a basic Unix shell is reachable via ADB or Java's Runtime package | Apple: third-party apps are sandboxed, run without the ability to escalate their own privileges, and unnecessary tools such as remote login services are not included in the system software |
| What an unprivileged shell can do | Runs with the calling app's sandbox permissions | ATT&CK's iOS analytics treat any shell spawn on stock iOS as a jailbreak indicator |
| Path to elevated commands | Root via exploit or existing root, then a superuser binary | Jailbreak or kernel exploit |
| Main enterprise signal | App vetting for process creation; attestation and MDM root detection | Jailbreak detection in MDM or MTD; app vetting on supervised devices |
| Development interface to control | USB debugging (ADB) in Developer options | Supervised device restrictions through MDM |
T1623.001 Unix Shell
ATT&CK describes Unix shells as the underlying command prompts on Android and iOS, able to control every aspect of the system, with some commands needing elevated privileges available only after rooting or jailbreaking. Shells also run scripts with conditionals and loops, may be reached through C2 channels or SSH, and may be used for persistence. On a rooted or jailbroken device, adversaries may locate and invoke a superuser binary and act as root.
Real cases recorded by ATT&CK for the sub-technique include:
| Software | Behaviour recorded by ATT&CK | Platform |
|---|---|---|
| AbstractEmu (S1061) | Included encoded shell scripts to potentially aid the rooting process; first seen in Google Play and other stores in October 2021 | Android |
| BusyGasper (S0655) | Can run shell commands | Android |
| CHEMISTGAMES (S0555) | Can run bash commands | Android |
| DoubleAgent (S0550) | Can run arbitrary shell commands | Android |
| HenBox (S0544) | Can run commands as root | Android |
| Sunbird (S1082) | Can try to run arbitrary commands as root | Android |
Parent technique cases
- LightSpy (S1185): plugins execute shell commands from the C2 server or from a library file called
zt.dylib. ATT&CK describes LightSpy as modular malware first observed in 2018 that initially targeted iOS devices in Southern Asia before expanding to Android and macOS. It is the clearest iOS example for this technique. - TianySpy (S1056): steals information via malicious JavaScript (Android).
- NGate (S9040): used Java to load and verify runtime configuration and to disable the launcher if decryption or parsing failed (Android).
For spyware response, see the Mobile Spyware Infection Response Playbook.
Detection
| Evidence | Android | iOS |
|---|---|---|
| Process creation | App invokes Runtime.exec(), ProcessBuilder.start() or a JNI-backed launcher with sh, bash, toybox, toolbox or su, and is not on an approved list | Managed app triggers process launch that results in a shell child process on a supervised device |
| Command execution | Shell child process of an app with arguments that indicate scripted operation | Shell or command-executing child process under an app context |
| Device state | Failed Play Integrity deviceIntegrity labels, unlocked bootloader in key attestation, MTD root detection | MDM or MTD jailbreak detection |
| Forensic artefacts | Superuser binaries, root framework packages, unexplained scripts in app data | Jailbreak artefacts; analysis of backups, filesystem dumps and sysdiagnose archives with MVT |
These rows follow ATT&CK's detection strategies DET0655 (parent) and DET0607 (Unix Shell). Most of the process-level evidence comes from instrumented app vetting, not from production devices: neither platform gives MDM a process list for every app. In production, rely on device state and MTD. For forensics, the Mobile Verification Toolkit (MVT) supports consensual analysis of iOS backups, filesystem dumps and sysdiagnose archives, and of Android backups.
Prevention
- Block rooted and jailbroken devices: ATT&CK M1002 and M1010. Require attestation for corporate access and mark compromised devices non-compliant.
- Control ADB: on managed Android devices, disable USB debugging and Developer options through MDM policy, since ADB is a documented route to the shell. See Android Platform Tools and ADB.
- Restrict app sources: block unknown sources on Android and use supervised iOS devices with managed app distribution, so apps carrying shell payloads are less likely to land.
- Patch promptly: rooting and jailbreaking usually need an unpatched flaw (see T1404 Exploitation for Privilege Escalation). ATT&CK maps M1001 Security Updates and M1006 Use Recent OS Version to that precondition, not to T1623 itself, which ATT&CK v20 maps to M1002 Attestation and M1010 Deploy Compromised Device Detection Method.
- App developers: do not build shell commands from user input or remote data in your own app; MASVS-CODE covers input handling and MASVS-RESILIENCE covers detecting an untrusted platform.
How to implement
- Baseline device state. Report root, jailbreak and attestation results across the fleet in audit mode for two weeks.
- Enforce compliance. Block corporate access from compromised devices through conditional access; keep a documented exception path for test devices.
- Lock down debug interfaces. Disable Developer options and USB debugging on managed Android devices; restrict host pairing on supervised iOS devices.
- Add vetting rules. Flag apps that spawn shells or call
su, and require justification for any approved exception. - Prepare response. Define when to collect an MVT or commercial acquisition, and when to wipe and re-provision.
- Roll back safely. If developers or test teams are blocked, scope exceptions to named devices rather than relaxing fleet policy.
Decision guidance
- Fully managed or supervised devices: disable debug interfaces and enforce compliance strictly.
- BYOD: you cannot disable ADB on personal profiles in every model; rely on attestation and MTD and restrict what corporate data reaches the device.
- High-risk users: where spyware like LightSpy is a realistic threat, add iOS Lockdown Mode or Android Advanced Protection and periodic forensic checks. See Android Advanced Protection and Mobile Communications Protection for High-Risk Individuals Guide.
Where identity fits
A shell running as root can read any app's private storage, including OAuth refresh tokens, API keys and MDM enrolment credentials. Treat a confirmed shell compromise on a device as a credential exposure: revoke and reissue tokens issued to that device, rotate any service credentials stored in apps on it, and re-enrol rather than clean in place. See the Mobile Access Credentials guide.
Metrics that show it is working
- Managed devices with Developer options or USB debugging enabled (target: zero outside named test devices).
- Rooted or jailbroken devices with corporate access (target: zero).
- Apps in vetting flagged for shell execution, and the share removed or justified.
- Time from compromised-device detection to token revocation.
Framework mapping
| Framework | Reference | Relevance |
|---|---|---|
| MITRE ATT&CK for Mobile | T1623, T1623.001; DET0655, DET0607; M1002, M1010 | Technique, detection strategies and listed mitigations |
| NIST CSF 2.0 | PR.PS-05, DE.CM-09 | Preventing unauthorised software; monitoring runtime environments |
| NIST SP 800-53 Rev 5 | CM-7, AC-19, SI-7, SI-3 | Least functionality, mobile device access control, integrity, malicious code protection |
| ISO/IEC 27001:2022 Annex A | A.8.1, A.8.7 | User endpoint devices, protection against malware |
| OWASP MASVS | MASVS-CODE, MASVS-RESILIENCE | Input handling; platform trust checks |
Common failure patterns
- Developer options left on: debug interfaces enabled for one-off support remain on across the fleet.
- Assuming iOS is immune: LightSpy shows shell-executing plugins on iOS; jailbreak detection still matters.
- Trusting on-device root checks: root frameworks can hide themselves; verify attestation on the server.
- Cleaning in place: a device that ran root shell commands should be wiped and re-enrolled, with its tokens revoked.
- Ignoring non-shell interpreters: JavaScript in WebViews and Java runtime loading are also listed by ATT&CK. See the Mobile WebView Security Guide.
Practitioner checklist
- Disable Developer options and USB debugging on managed Android devices.
- Block corporate access from rooted or jailbroken devices.
- Verify attestation on the server.
- Flag shell and
suexecution in app vetting. - Keep OS and security patches current through compliance rules.
- Revoke tokens and re-enrol any device with confirmed shell compromise.
- Define when to run an MVT or commercial forensic acquisition.
Standards and references
- MITRE ATT&CK: T1623 Command and Scripting Interpreter
- MITRE ATT&CK: T1623.001 Unix Shell
- Apple Platform Security: Runtime process security
- Android Developers: Play Integrity API overview
- Android Developers: Verify hardware-backed key pairs with key attestation
- OWASP: Mobile Application Security Verification Standard
- Amnesty International Security Lab: Mobile Verification Toolkit documentation
Related NHI Mgmt Group resources: MITRE ATT&CK for Mobile Guide · T1059 Command and Scripting Interpreter Defensive Guide · Rooted, jailbroken and emulated devices · Mobile Forensics Guide · Mobile Device Management Security Guide