AWS EC2 CreateKeyPair by New Principal from Non-Cloud AS Organization
Description
Identifies the first time a given IAM principal successfully creates an EC2 key pair when the request is sourced from a
network whose autonomous system organization is not attributed to common cloud or hyperscaler providers in your GeoIP
data. Adversaries may call CreateKeyPair to stage SSH access material before launching or accessing instances. A new
terms baseline on user_identity.arn suppresses repeated noise from the same principal while still surfacing the initial
suspicious creation from an unusual egress label.
Query · kuery
event.dataset: "aws.cloudtrail"
and event.provider: "ec2.amazonaws.com"
and event.action: "CreateKeyPair"
and event.outcome: "success"
and source.as.organization.name: (
* and not (
"Amazon.com, Inc." or AMAZ* or "Google LLC" or "Microsoft Corporation"
)
)
Investigation fields
Pivot points the source recommends for triage.
@timestampuser.nameuser_agent.originalsource.ipsource.as.organization.nameaws.cloudtrail.user_identity.arnaws.cloudtrail.user_identity.typeaws.cloudtrail.user_identity.access_key_idevent.actionevent.outcomecloud.account.idcloud.regionaws.cloudtrail.request_parametersaws.cloudtrail.response_elements
Known false positives
- Engineers creating key pairs from home ISP, corporate VPN, or colocation AS names will match until baselined. GeoIP databases vary by vendor; organization labels may differ slightly from the excluded strings (for example alternate Amazon or Google legal names). Tune exclusions on `source.as.organization.name` or principal ARN after validation.
Analyst notes
Investigating AWS EC2 CreateKeyPair by New Principal from Non-Cloud AS Organization
CreateKeyPair creates an Amazon EC2 SSH key pair in the account; the private key material is returned to the caller
once. This is useful for persistence or preparation for instance access.
This new terms rule alerts the first time aws.cloudtrail.user_identity.arn matches the query within the
configured history window. Subsequent key-pair creations by the same principal (still matching the query) are
suppressed until the term ages out of the window.
Possible investigation steps
- Review
aws.cloudtrail.request_parameters/response_elementsforkeyNameand whether the key aligns with change management. - Correlate
source.ip,source.geo, anduser_agent.originalwith the principal’s normal admin paths. - Hunt for
RunInstances,ImportKeyPair, or Instance Connect activity involving the same key name or actor.
False positive analysis
- First-time legitimate admin activity from a new office or VPN provider.
- Missing
source.as.organization.nameenrichment would not match the query’s positive wildcard; confirm fields are populated if you expect coverage.
Response and remediation
- If unauthorized: delete the key pair (
DeleteKeyPair), review IAM forec2:CreateKeyPair, and rotate any credentials used by the actor.