AWS EC2 Instance Launched With User Data by Rare User

Last updated 10 days ago on 2026-11-11
Created 10 days ago on 2026-11-11

About

Identifies the first time, within a lookback window, an identity launches an EC2 instance that includes user data via the "RunInstances" API. Adversaries supply user data to execute code automatically on instance boot (cloud-init), enabling command execution, persistence, or credential theft from a newly created, attacker-controlled instance. This is a New Terms rule detecting a rare occurrence of the "cloud.account.id", "user.name", and "source.as.organization.name" tuple for instance launches carrying user data.
Tags
Domain: CloudData Source: AWSData Source: Amazon Web ServicesPlatform: AWSData Source: AWS CloudTrailService: AWS EC2Tactic: Defense EvasionRule Type: New TermsLanguage: kuery
Severity
medium
Risk Score
47
MITRE ATT&CK™

Defense Evasion (TA0005)(external, opens in a new tab or window)

False Positive Examples
Infrastructure-as-code pipelines, auto scaling, and launch-template-driven deployments routinely launch instances with user data. Terraform and service-invoked (Auto Scaling, CloudFormation) launches are excluded, but other automation or administrators bootstrapping instances may generate first-seen matches that warrant review.
License
Elastic License v2(external, opens in a new tab or window)

Definition

Rule Type
New Terms Rule
Integration Pack
Prebuilt Security Detection Rules
Index Patterns
logs-aws.cloudtrail-*
Related Integrations

aws(external, opens in a new tab or window)

Query
text code block:
data_stream.dataset: "aws.cloudtrail" and event.provider: "ec2.amazonaws.com" and event.action: "RunInstances" and event.outcome: "success" and source.ip: * and cloud.account.id: * and user.name: * and aws.cloudtrail.request_parameters: *userData* and source.as.organization.name: ( * and not ( "Google LLC" or "Amazon.com, Inc." or "Microsoft Corporation" or "GOOGLE-CLOUD-PLATFORM" or "MICROSOFT-CORP-MSN-AS-BLOCK" or "AMAZON-AES" or "AMAZON-02" ) ) and not aws.cloudtrail.user_identity.invoked_by: ("autoscaling.amazonaws.com" or "cloudformation.amazonaws.com") and not user_agent.original: (*Terraform*)

Install detection rules in Elastic Security

Detect AWS EC2 Instance Launched With User Data by Rare User in the Elastic Security detection engine by installing this rule into your Elastic Stack.

To setup this rule, check out the installation guide for Prebuilt Security Detection Rules(external, opens in a new tab or window).