Techniques
Sample rules
AWS Discovery API Calls via CLI from a Single Resource
- source: elastic
- technicques:
- T1580
Description
Detects when a single AWS resource is running multiple Describe
and List
API calls in a 10-second window. This
behavior could indicate an actor attempting to discover the AWS infrastructure using compromised credentials or a
compromised instance. Adversaries may use this information to identify potential targets for further exploitation or to
gain a better understanding of the target’s infrastructure.
Detection logic
from logs-aws.cloudtrail*
// create time window buckets of 10 seconds
| eval Esql.time_window_date_trunc = date_trunc(10 seconds, @timestamp)
| where
event.dataset == "aws.cloudtrail"
// filter on CloudTrail audit logs for IAM, EC2, S3, etc.
and event.provider in (
"iam.amazonaws.com",
"ec2.amazonaws.com",
"s3.amazonaws.com",
"rds.amazonaws.com",
"lambda.amazonaws.com",
"dynamodb.amazonaws.com",
"kms.amazonaws.com",
"cloudfront.amazonaws.com",
"elasticloadbalancing.amazonaws.com"
)
// ignore AWS service actions
and aws.cloudtrail.user_identity.type != "AWSService"
// filter for aws-cli specifically
and user_agent.name == "aws-cli"
// exclude DescribeCapacityReservations events related to AWS Config
and not event.action in ("DescribeCapacityReservations")
// filter for Describe, Get, List, and Generate API calls
| where true in (
starts_with(event.action, "Describe"),
starts_with(event.action, "Get"),
starts_with(event.action, "List"),
starts_with(event.action, "Generate")
)
// extract owner, identity type, and actor from the ARN
| dissect aws.cloudtrail.user_identity.arn "%{}::%{Esql_priv.aws_cloudtrail_user_identity_arn_owner}:%{Esql.aws_cloudtrail_user_identity_arn_type}/%{Esql.aws_cloudtrail_user_identity_arn_roles}"
| where starts_with(Esql.aws_cloudtrail_user_identity_arn_roles, "AWSServiceRoleForConfig") != true
// keep relevant fields (preserving ECS fields and computed time window)
| keep @timestamp, Esql.time_window_date_trunc, event.action, aws.cloudtrail.user_identity.arn
// count the number of unique API calls per time window and actor
| stats
Esql.event_action_count_distinct = count_distinct(event.action)
by Esql.time_window_date_trunc, aws.cloudtrail.user_identity.arn
// filter for more than 5 unique API calls per 10s window
| where Esql.event_action_count_distinct > 5
// sort the results by the number of unique API calls in descending order
| sort Esql.event_action_count_distinct desc