Targeted mobile malware often stays dormant unless it finds itself on the intended victim's device, in the intended country, which means an analyst's sandbox can see nothing at all. MITRE ATT&CK for Mobile records this as T1627 Execution Guardrails, a Defense Evasion technique with one sub-technique, T1627.001 Geofencing. ATT&CK v20 lists it for both Android and iOS. This guide explains how guardrails differ from sandbox evasion, how location-based guardrails work on each platform, which OS permission controls limit them, and how MDM, MTD and app vetting teams can still catch them. It is for mobile security engineers, threat analysts and administrators of high-risk user fleets. For the wider matrix, see the MITRE ATT&CK for Mobile Guide.
Key takeaways
- Guardrails look for a match, not a sandbox. ATT&CK distinguishes guardrails, which continue only if a target-specific value is present, from system checks, which stop if sandbox values are found.
- Location needs a permission. On both platforms, geofencing requires the user to grant location access; background geofencing needs the stronger grant.
- Vetting must vary the environment. Run dynamic analysis with simulated locations, locales and device states that match your real users, or guarded code paths never execute.
- Permission hygiene is the lasting control. Denying background and precise location to apps that do not need it removes the input many guardrails rely on.
- Parity matters. Android and iOS both expose geofencing APIs and both let users limit location to while-in-use; apply equivalent controls on each.
What T1627 is
ATT&CK defines Execution Guardrails as constraining execution to adversary-supplied, environment-specific conditions expected on the target, so a payload runs only against the intended target and collateral damage is reduced. Location is the example ATT&CK gives. The technique differs from Mobile T1633 Virtualization/Sandbox Evasion: a sandbox check continues when no known analysis value is found, while a guardrail continues only when an expected target value is found.
T1627.001 Geofencing on Android and iOS
ATT&CK notes that geofencing starts with persuading the user to grant location access; the app can then collect and process the device's location to stop malicious behaviour, show region-specific content, or release a second stage only in a chosen region. Both platforms provide official APIs that make this simple. Platforms are listed alphabetically.
| Aspect | Android | iOS |
|---|---|---|
| Official API | Geofencing API in Google Play services location: GeofencingClient.addGeofences() with ENTER, EXIT and DWELL transitions | Core Location region monitoring through CLLocationManager |
| Permission levels | ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION for foreground; ACCESS_BACKGROUND_LOCATION from Android 10 (API 29) | When in Use (requestWhenInUseAuthorization()) or Always (requestAlwaysAuthorization()) |
| Permission needed for geofencing | ACCESS_FINE_LOCATION, plus ACCESS_BACKGROUND_LOCATION when targeting API 29 or higher | Always authorization lets the system launch a terminated app for region monitoring events |
| Declared purpose | Permissions declared in AndroidManifest.xml | NSLocationWhenInUseUsageDescription; NSLocationAlwaysAndWhenInUseUsageDescription for Always |
| Accuracy controls | Approximate (about 3 square km) or precise (usually about 50 m) | Users can limit when an app accesses location, including one-time and while in use (per ATT&CK) |
| Practical limits | 100 geofences per app per device user; background events arrive every couple of minutes on Android 8.0 and higher | Users can change authorisation at any time in Settings |
Geofencing is not the only guardrail. ATT&CK records country and language checks, device checks and channel checks too.
Procedure examples from ATT&CK
| Software or group | Platform context | Behaviour recorded by ATT&CK v20 |
|---|---|---|
| Binary Validator (S1215) | iOS | Checked whether the device is jailbroken (T1627) |
| BRATA (S1094) | Android | Performed country and language checks (T1627.001) |
| DocSwap (S9005) | Android | Checked whether the victim opened the malicious URL from a PC and, if so, redirected them to scan a QR code on a mobile device (T1627) |
| eSurv (S0507) | Android and iOS | Imposes geo-restrictions when delivering the second stage (T1627.001) |
| Windshift (G0112) | Mobile apps | Region-locked malicious applications during the Operation BULL campaign (T1627.001) |
T1627.001 replaced the older Mobile ID T1581 Geofencing, which ATT&CK now marks as revoked.
Detection: catching code that waits for the right place
MITRE's detection strategy for Geofencing (DET0648) correlates three things: an app holding location permission sufficient for continuous evaluation, repeated location checks or geofence registration while the app is in the background or barely used, and a sudden start of network traffic, background work or new features only after the device enters, leaves or stays in a region. ATT&CK notes that on iOS direct visibility of geofence callbacks is weaker, so defenders lean more on authorisation state, repeated location access, app state changes and downstream behaviour.
The parent strategy (DET0653) adds a burst of environment checks at cold launch before any user interaction, such as device model, OS version and enrolment state, observed through app vetting, Android Enterprise managed app inventory and permission state, or Apple MDM InstalledApplicationList and ManagedApplicationList queries.
| Signal | Android source | iOS source |
|---|---|---|
| Background location granted to an app with no location feature | Android Enterprise permission grant state; MTD | App privacy usage keys in vetting; MTD where supported |
| Geofence registration or region monitoring soon after install | Dynamic analysis trace | Dynamic analysis trace |
| Environment checks before first user interaction | Dynamic analysis trace | Dynamic analysis trace |
| Network or download activity only under simulated target locale or location | Sandbox with location and locale variation | Sandbox with location and locale variation |
| App installed outside managed channels | MDM inventory; Play Integrity UNKNOWN_INSTALLED | MDM managed versus unmanaged app list |
Making app vetting resistant to guardrails
- Profile your users: list the countries, languages and carriers your workforce actually uses.
- Run each sample several times with simulated locations and locales from that list, not just the lab's default.
- Compare behaviour across runs: new network destinations, downloads or permissions requested under one profile and not another indicate a guardrail.
- Flag location permission without a feature: a utility or flashlight app asking for background or precise location goes to manual review.
- Feed results back into MDM allow and block lists so the decision applies across the fleet.
Metrics
- Percentage of managed apps holding background location, with a documented business need for each.
- Percentage of vetted apps analysed under more than one location and locale profile.
- Number of apps installed outside managed channels.
- Percentage of devices on a current OS release (M1006).
- Median time from a high-risk vetting result to block in MDM.
Prevention: permission controls and policy
- Least location privilege (M1011 User Guidance): ATT&CK advises users to scrutinise apps requesting location or sensitive phone information and deny requests from apps they do not recognise. Reinforce this in awareness training for high-risk users.
- Android: prefer while-in-use grants; background location is requested separately from Android 10 onward. Keep Play Protect on and restrict installs to managed Google Play on corporate devices. See Mobile App Permissions and the Android Security and Privacy Settings Guide.
- iOS: prefer When in Use; Apple notes an app with When in Use authorisation is not launched by the system to deliver updates once terminated, unlike Always. Manage app distribution through MDM. See the iOS and iPadOS Enterprise Security Guide.
- Recent OS (M1006): ATT&CK notes new OS releases often add limits on location access.
- High-risk users: Apple's Lockdown Mode, available from iOS 16, reduces the attack surface that mercenary spyware could exploit; note that it blocks configuration profile installation and MDM enrolment, so plan management before enabling it. On Android, see Android Advanced Protection. Both are covered in the Mobile Communications Protection for High-Risk Individuals Guide.
Response
A geofenced sample found in vetting tells you who was targeted. Check MDM inventory for the same app across the fleet, prioritise devices of users in the targeted region or role, and acquire consensual forensic images of those devices before removal. See the Mobile Spyware Infection Response Playbook and the Mobile Verification Toolkit (MVT). Revoke tokens and certificates held by any device where the payload is confirmed active.
Framework mapping
| Framework | Reference | Relevance |
|---|---|---|
| ATT&CK for Mobile | M1006 Use Recent OS Version, M1011 User Guidance | Mitigations ATT&CK maps to T1627 and T1627.001 |
| NIST SP 800-53 Rev 5 | AC-19 Access Control for Mobile Devices, CM-7 Least Functionality, CM-11 User-installed Software, SI-4 System Monitoring | Limit permissions and installs, monitor behaviour |
| NIST CSF 2.0 | PR.PS-05, ID.AM-02, DE.CM-09 | Software control, inventory, runtime monitoring |
| OWASP MASVS | MASVS-PRIVACY | Data minimisation for location in your own apps |
Common failure patterns
- Single-run sandboxing: one analysis run in the lab's own country sees a benign app.
- Treating location as low risk: background location grants are approved without asking why.
- Android-only vetting: ATT&CK lists iOS too, and eSurv is recorded across both platforms.
- Removing the sample without hunting: a guardrail implies a target list; other devices may hold the same app.
- Lockdown Mode surprises: enabling it on managed devices without checking it blocks MDM enrolment.
Practitioner checklist
- Review every managed app holding background or Always location.
- Run dynamic analysis under several location and locale profiles that match your users.
- Flag environment checks that run before first user interaction.
- Restrict installs to managed channels on both Android and iOS.
- Keep devices on current OS releases.
- Offer Lockdown Mode or Advanced Protection to high-risk users, with a management plan.
- Hunt fleet-wide for any guarded sample found in vetting.
Standards and references
- MITRE ATT&CK: Execution Guardrails (Mobile T1627)
- MITRE ATT&CK: Geofencing (Mobile T1627.001)
- Android Developers: Create and monitor geofences
- Android Developers: Request location permissions
- Apple Developer: Requesting authorization to use location services
- Apple Support: About Lockdown Mode
- OWASP: Mobile Application Security Verification Standard
Related NHI Mgmt Group resources: MITRE ATT&CK for Mobile Guide · MITRE ATT&CK T1480 Execution Guardrails · Mobile App Security Testing Guide · Mobile Threat Defense Buyer's Guide