AWS EC2 Stop, Start, and User Data Modification Correlation
Identifies a short sequence of EC2 management APIs against the same instance that is consistent with modifying instance user data and forcing it to run on the next boot: `ModifyInstanceAttribute` with user data,…
Description
Identifies a short sequence of EC2 management APIs against the same instance that is consistent with modifying instance user data and forcing it to run on the next boot: `ModifyInstanceAttribute` with user data, followed by stop and start. Adversaries may update `userData` and cycle instance state so malicious scripts execute as root on Linux or as the system context on Windows. This rule correlates successful `StopInstances`, `StartInstances`, and `ModifyInstanceAttribute` events that reference `userData` within a five-minute window, grouped by instance, `user.name`, account, source IP, and user agent. A hit requires exactly three distinct API names in that bucket.
Detection logic
Its licence does not clear it for publishing here
Sunturai publishes a detection's own text where the licence it arrived under has been reviewed and permits it, and Elastic License 2.0 has not. The query as its source wrote it, its canonical form and the hash that pins this revision are in the workspace record.
Detection requirements
- Platform
- ContainersESXiIaaSIdentity ProviderLinuxmacOSNetwork DevicesOffice SuiteSaaSWindows
The rule states no platform. This is derived from the 2 ATT&CK techniques it maps to.
Known benign triggers
- Legitimate automation or administrators may change user data and restart instances during maintenance, image baking, or configuration fixes. Review the caller identity, change tickets, and whether `user_agent.original` and `source.ip` match known tooling and networks (the rule groups on both together with `user.name`).
MITRE ATT&CK mappings
0 exclusive techniques.This is coverage no other published rule has; it is not this rule's total technique count.
References
| Reference | Cited by |
|---|---|
| docs.aws.amazon.com/AWSEC2/latest/APIReference/API_ModifyInstanceAttribute.html | Only this detection cites it |
| hackingthe.cloud/aws/exploitation/local_ec2_priv_esc_through_user_data | 2 |
From the source
- At source
- Open at source
- Upstream identifier
- 7e5c0e5a-95a5-404e-a5b0-278d35dc3325
- Tagged by the source as
- Data Source: Amazon Web ServicesData Source: AWSData Source: AWS CloudTrailData Source: AWS EC2Domain: CloudNoise: UnknownPerformance: NormalPlatform: AWSResources: Investigation GuideRule Type: ES|QLService: AWS EC2Tactic: ExecutionUse Case: Threat Detection
Licence
- Published under
- Elastic License 2.0Read the licence
- Attribution
- Required
Authorship
- Written by
- Published
- Sep 20, 2026
- Version
- 3