Detection: AWS CreateAccessKey

Description

This hunting query identifies successful AWS IAM access key creation events where a named IAM user creates a key for a different named IAM user. Such activity may indicate persistence or privilege escalation, particularly when the target user has elevated permissions. The query compares the caller and target usernames; it does not assess the target user's permissions. Hunting queries are designed to be run manually during threat hunting activities.

 1`cloudtrail`
 2eventName = CreateAccessKey
 3
 4
 5| where (isnull(errorCode) OR errorCode="success")
 6        AND 'userIdentity.type'="IAMUser"
 7        AND isnotnull('userIdentity.userName')
 8        AND isnotnull('requestParameters.userName')
 9        AND 'userIdentity.userName'!='requestParameters.userName'
10
11
12| eval
13       caller_arn='userIdentity.arn',
14       caller_principal_id='userIdentity.principalId',
15       caller_user='userIdentity.userName',
16       dest=coalesce(dest,eventSource),
17       signature=coalesce(signature,eventName),
18       src=coalesce(src,sourceIPAddress),
19       target_user='requestParameters.userName',
20       user_agent=coalesce(user_agent,userAgent),
21       user_arn=coalesce(user_arn,caller_arn),
22       vendor_account=coalesce(vendor_account,recipientAccountId),
23       vendor_product=coalesce(vendor_product,"AWS"),
24       vendor_region=coalesce(vendor_region,awsRegion)
25
26
27| stats count min(_time) as firstTime
28              max(_time) as lastTime
29              values(dest) as dest
30              values(eventID) as eventIDs
31              values(signature) as signature
32              values(src) as src
33              values(user_agent) as user_agent
34              values(user_arn) as user_arn
35              values(vendor_product) as vendor_product
36              values(vendor_region) as vendor_region
37
38  by vendor_account caller_user caller_principal_id target_user
39
40
41| `security_content_ctime(firstTime)`
42
43| `security_content_ctime(lastTime)`
44
45| `aws_createaccesskey_filter`

Data Source

Name Platform Sourcetype Source
AWS CloudTrail CreateAccessKey AWS icon AWS 'aws:cloudtrail' 'aws_cloudtrail'

Macros Used

Name Value
security_content_ctime convert timeformat="%Y-%m-%dT%H:%M:%S" ctime($field$)
aws_createaccesskey_filter search *
aws_createaccesskey_filter is an empty macro by default. It allows the user to filter out any results (false positives) without editing the SPL.

Annotations

- MITRE ATT&CK
+ Kill Chain Phases
+ NIST
+ CIS
- Threat Actors
ID Technique Tactic
T1136.003 Cloud Account Persistence
Installation
DE.AE
CIS 13

Default Configuration

This detection is configured by default in Splunk Enterprise Security to run with the following settings:

Setting Value
Disabled true
Cron Schedule 0 * * * *
Earliest Time -70m@m
Latest Time -10m@m
Schedule Window auto
Creates Finding (Notable) No
Creates Intermediate Finding (Risk Event) No
Hunting detections do not generate a Finding (Notable) or Intermediate Findings (Risk Events).

Implementation

You must install splunk AWS add on and Splunk App for AWS. This search works with AWS CloudTrail logs.

Known False Positives

While this search has no known false positives, it is possible that an AWS admin has legitimately created keys for another user.

Associated Analytic Story

References

Detection Testing

Test Type Status Dataset Source Sourcetype
Validation ✅ Passing N/A N/A N/A
Unit ✅ Passing Dataset aws_cloudtrail aws:cloudtrail

Replay any dataset to Splunk Enterprise by using our replay.py tool or the UI. Alternatively you can replay a dataset into a Splunk Attack Range


Source: GitHub |

Version: 12