AWS EC2 Bulk User Data Enumeration

Last updated 2 days ago on 2026-11-01
Created 2 days ago on 2026-11-01

About

Identifies when the same AWS principal, from the same source IP, successfully calls EC2 "DescribeInstanceAttribute" for the "userData" attribute against more than 20 distinct instances within a 10-minute lookback. Instance user data often contains bootstrap scripts and hardcoded credentials, so retrieving it across many instances in a short window can indicate reconnaissance or credential harvesting. Known CSPM roles, AWS service invocations, and Terraform calls from major cloud and carrier networks are excluded.
Tags
Domain: CloudData Source: AWSData Source: Amazon Web ServicesData Source: AWS CloudTrailPlatform: AWSService: AWS EC2Use Case: Threat DetectionTactic: DiscoveryTactic: Credential AccessRule Type: ES|QLLanguage: esql
Severity
high
Risk Score
73
MITRE ATT&CK™

Discovery (TA0007)(external, opens in a new tab or window)

Credential Access (TA0006)(external, opens in a new tab or window)

False Positive Examples
Inventory jobs, configuration management, and security scanners that are not in the exclusion list may read `userData` across a large fleet. Confirm the principal ARN, source IP, ASN, and user agent against approved automation before treating the activity as malicious. Terraform running from an ASN other than Amazon, Google, Microsoft, Verizon, or AT&T is still in scope. A large apply or refresh can exceed 20 instances.
License
Elastic License v2(external, opens in a new tab or window)

Definition

Integration Pack
Prebuilt Security Detection Rules
Related Integrations

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

Query
text code block:
from logs-aws.cloudtrail-* | where KQL("""event.provider: "ec2.amazonaws.com" and event.action: "DescribeInstanceAttribute" and event.outcome: "success" and aws.cloudtrail.flattened.request_parameters.attribute: "userData" and source.ip: * and source.as.organization.name: * and not user.name: (*CrowdStrikeCSPMReader* or *OrcaSecurityRole* or *AikidoSecurityRole* or *streamsec-*) and not aws.cloudtrail.user_identity.invoked_by: ("AWS Internal" or "cloudformation.amazonaws.com" or "aidevops.amazonaws.com" or "elasticmapreduce.amazonaws.com" or "aiops.amazonaws.com")""") and not ( user_agent.original like "*Terraform*" and source.as.organization.name in ( "Amazon.com, Inc.", "Google LLC", "Microsoft Corporation", "Verizon Business", "AT&T Enterprises, LLC" ) ) | grok aws.cloudtrail.request_parameters """instanceId=(?<Esql.instance_id>[^,}\]]+)""" | where Esql.instance_id is not null | stats Esql.count_distinct_instance_id = count_distinct(Esql.instance_id), Esql.aws_request_parameters_values = values(aws.cloudtrail.request_parameters), Esql.user_agent_values = values(user_agent.original) by data_stream.namespace, aws.cloudtrail.user_identity.arn, aws.cloudtrail.user_identity.type, source.as.organization.name, source.ip, source.`as`.number | where Esql.count_distinct_instance_id > 20 | keep Esql.count_distinct_instance_id, data_stream.namespace, aws.cloudtrail.user_identity.arn, aws.cloudtrail.user_identity.type, source.ip, source.`as`.number, source.as.organization.name, Esql.aws_request_parameters_values, Esql.user_agent_values

Install detection rules in Elastic Security

Detect AWS EC2 Bulk User Data Enumeration 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).