| ID | Technique | Tactic |
|---|---|---|
| T1087.004 | Cloud Account | Discovery |
Detection: AWS Identity Verification Followed by IAM Discovery
Description
The following analytic detects a successful AWS STS GetCallerIdentity call followed by ListAccessKeys, ListAttachedUserPolicies, ListRoles, or ListUsers from the same caller ARN within five minutes. It returns one finding per matching identity-check session and summarizes the subsequent IAM discovery. This behavior may indicate identity verification and enumeration following credential compromise, but it is also performed by legitimate applications and administrative tools. The correlation uses the caller ARN and does not require the same access-key ID or source address.
Search
1`cloudtrail`
2(
3 (
4 eventSource="sts.amazonaws.com"
5 eventName="GetCallerIdentity"
6 )
7 OR
8 (
9 eventSource="iam.amazonaws.com"
10 eventName IN (
11 "ListAccessKeys",
12 "ListAttachedUserPolicies",
13 "ListRoles",
14 "ListUsers"
15 )
16 )
17)
18
19
20| eval user_arn='userIdentity.arn',
21 src=coalesce(src, sourceIPAddress),
22 event_time=_time
23
24
25| where isnotnull(user_arn)
26
27
28| dedup eventID keepempty=true
29
30
31| eval is_identity_check=if(
32 eventName="GetCallerIdentity"
33 AND (
34 isnull(errorCode)
35 OR errorCode=""
36 OR lower(errorCode)="success"
37 ),
38 1,
39 0
40)
41
42
43| eval identity_time=if(is_identity_check=1, event_time, null())
44
45
46| sort 0 event_time
47
48
49| streamstats current=t
50 max(identity_time) AS session_start
51 BY user_arn
52
53
54| eval elapsed_seconds=event_time-session_start
55
56
57| where elapsed_seconds>=0 AND elapsed_seconds<=300
58
59
60| eval additional_api=if(
61 eventName!="GetCallerIdentity" AND elapsed_seconds>0,
62 eventName,
63 null()
64 ),
65 discovery_time=if(isnotnull(additional_api), event_time, null()),
66 discovery_source=if(isnotnull(additional_api), src, null())
67
68
69| eventstats count(additional_api) AS discovery_calls
70 dc(additional_api) AS distinct_discovery_apis
71 max(discovery_time) AS last_discovery_time
72 min(discovery_time) AS first_discovery_time
73 values(additional_api) AS additional_apis
74 values(discovery_source) AS discovery_src
75 BY user_arn session_start
76
77
78| where is_identity_check=1 AND discovery_calls>0
79
80
81| sort 0 - session_start
82
83
84| eval user=user_arn,
85 firstTime=session_start,
86 lastTime=last_discovery_time,
87 identity_check_at=session_start,
88 first_discovery_at=first_discovery_time,
89 last_discovery_at=last_discovery_time,
90 sequence_duration_seconds=last_discovery_time-session_start
91
92
93| table firstTime lastTime identity_check_at eventName user
94 user_arn src first_discovery_at last_discovery_at
95 additional_apis discovery_src distinct_discovery_apis
96 discovery_calls sequence_duration_seconds
97
98
99| `security_content_ctime(firstTime)`
100
101| `security_content_ctime(lastTime)`
102
103| `security_content_ctime(identity_check_at)`
104
105| `security_content_ctime(first_discovery_at)`
106
107| `security_content_ctime(last_discovery_at)`
108
109| `aws_identity_verification_followed_by_iam_discovery_filter`
Data Source
| Name | Platform | Sourcetype | Source |
|---|---|---|---|
| AWS CloudTrail | 'aws:cloudtrail' |
'aws_cloudtrail' |
Macros Used
| Name | Value |
|---|---|
| security_content_ctime | convert timeformat="%Y-%m-%dT%H:%M:%S" ctime($field$) |
| aws_identity_verification_followed_by_iam_discovery_filter | search * |
aws_identity_verification_followed_by_iam_discovery_filter is an empty macro by default. It allows the user to filter out any results (false positives) without editing the SPL.
Annotations
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) | Yes |
| Rule Title | %name% |
| Rule Description | %description% |
| Notable Event Fields | user, dest |
| Creates Intermediate Finding (Risk Event) | No |
Implementation
You must install Splunk AWS Add on and enable CloudTrail logs in your AWS Environment.
Known False Positives
Applications, inventory tools, security scanners, deployment pipelines, and administrators may verify their identity before enumerating IAM resources. Legitimate application activity produced matches during initial research. Review the caller ARN, source addresses, and normal discovery behavior before escalating. Same-ARN correlation may group activity performed with different credentials. Same-timestamp discovery is excluded because its order cannot be confirmed. Each successful identity check starts a new session.
Associated Analytic Story
Finding
| Title | Entity Field | Entity Type | Risk Score |
|---|---|---|---|
| AWS identity [$user$] verified its identity and performed [$discovery_calls$] IAM discovery calls | user | user | 20 |
Threat Objects
| Field | Type |
|---|---|
| src | ip_address |
References
-
https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListUsers.html
-
https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListAttachedUserPolicies.html
-
https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListRoles.html
-
https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListAccessKeys.html
-
https://docs.aws.amazon.com/STS/latest/APIReference/API_GetCallerIdentity.html
Detection Testing
| Test Type | Status | Dataset | Source | Sourcetype |
|---|---|---|---|---|
| Validation | ✅ Passing | N/A | N/A | N/A |
| Unit | ✅ Passing | Dataset | aws_cloudtrail |
aws:cloudtrail |
| Integration | ✅ 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: 1