Skip to content

Commit f927e2f

Browse files
imays11tradebot-elastic
authored andcommitted
[Rule Tuning] AWS IAM API Calls via Temporary Session Tokens (#5310)
* [Rule Tuning] AWS IAM API Calls via Temporary Session Tokens Came across some false positives as I was rule testing. Temporary credentials are also created for AWS Internal operations and when an AWS service operates on your behalf. These both should be excluded from results. I saw this in my own testing, in prod data and in our alert telemetry. These cases can be excluded by looking for `source.ip:*` as this field is not populated for those internal AWS operations. NOTE: Another false positive instance has been highlighted in the investigation guide. A legitimate AWS console login session is given temporary (ASIA) credentials which are populated for all the operations performed during that session. The only way to distinguish between these events and other temporary session token events, like those granted via AssumeRole or GetSessionToken, is with a field populated as `sessionCredentialFromConsole: true`. Right now our Integration does not map this field and it can only be found in `event.original`. I am putting in an Integration request to populate this field, which we could then use to further reduce false positives for rules like this. - updated description , false positives, and investigation guide - added `source.ip:*` to query * excluding AWS Internal user agent excluding AWS Internal user agent (cherry picked from commit 5bea1b3)
1 parent 120d558 commit f927e2f

File tree

1 file changed

+105
-50
lines changed

1 file changed

+105
-50
lines changed

rules/integrations/aws/persistence_iam_api_calls_via_user_session_token.toml

Lines changed: 105 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,109 @@
22
creation_date = "2025/04/16"
33
integration = ["aws"]
44
maturity = "production"
5-
updated_date = "2025/07/10"
5+
updated_date = "2025/11/12"
66

77
[rule]
88
author = ["Elastic"]
99
description = """
10-
Detects use of sensitive AWS IAM API operations using temporary credentials (session tokens starting with 'ASIA'). This may indicate credential theft or abuse of elevated access via a stolen session. It is not common for legitimate users to perform sensitive IAM operations with temporary session tokens.
10+
Detects sensitive AWS IAM API operations executed using temporary session credentials (access key IDs beginning with
11+
"ASIA"). Temporary credentials are commonly issued through sts:GetSessionToken, sts:AssumeRole, or AWS SSO logins and
12+
are meant for short-term use. It is unusual for legitimate users or automated processes to perform privileged IAM
13+
actions (e.g., creating users, updating policies, or enabling/disabling MFA) with session tokens. This behavior may
14+
indicate credential theft, session hijacking, or the abuse of a privileged role’s temporary credentials.
1115
"""
1216
false_positives = [
1317
"""
14-
Some CI/CD pipelines or administrative users may use session tokens. Review user context, IP, and timing to validate.
18+
Some CI/CD pipelines or administrative users may use session tokens. Review user context, IP, and timing to
19+
validate. Console login sessions result in temporary "ASIA" credentials and can typically be ignored for this alert.
20+
This can be verified in "event.original" as "sessionCredentialFromConsole: true"
1521
""",
1622
]
1723
from = "now-6m"
1824
index = ["filebeat-*", "logs-aws.cloudtrail-*"]
1925
language = "kuery"
2026
license = "Elastic License v2"
2127
name = "AWS IAM API Calls via Temporary Session Tokens"
22-
note = """
23-
## Triage and analysis
28+
note = """## Triage and analysis
2429
25-
### Investigating AWS IAM API Calls via Temporary Session Tokens
26-
27-
This rule detects sensitive IAM API operations performed using temporary AWS credentials (session tokens starting with 'ASIA'). These are short-lived credentials commonly obtained via sts:GetSessionToken, sts:AssumeRole, or AWS SSO login. While temporary credentials are often used for development and automation, they are rarely associated with direct IAM manipulation and may indicate credential theft, privilege escalation, or abuse of developer access.
28-
29-
#### Possible investigation steps:
30-
31-
- Review `aws.cloudtrail.user_identity.arn` to determine which IAM user or assumed role initiated the request.
32-
- Check `aws.cloudtrail.user_identity.access_key_id` to confirm if the credential starts with 'ASIA', indicating a temporary session token.
33-
- Examine `aws.cloudtrail.user_identity.session_context.mfa_authenticated` to verify whether MFA was present during session creation.
34-
- Investigate `source.ip` to assess whether the request originated from a known network, office IP, or corporate VPN.
35-
- Look at `user_agent.original` to determine if the API call came from a known CLI version or unexpected tool (e.g., unknown SDK, custom script).
36-
- Confirm whether a recent sts:GetSessionToken, sts:AssumeRole, or AWS SSO login event issued the temporary credential.
37-
- Correlate other events using the same access key ID to identify additional privileged actions, such as iam:CreateAccessKey, iam:PutUserPolicy, or iam:EnableMFADevice.
38-
- Analyze timing via @timestamp to determine if the action occurred during off-hours or deviates from normal user behavior.
39-
- Review the `event.outcome` to check if the API call was successful or failed, which may indicate unauthorized access attempts.
40-
- Check for related events in the same session, such as iam:CreateUser, iam:AttachUserPolicy, or sts:GetCallerIdentity, to identify potential lateral movement or privilege escalation.
41-
42-
### False positive analysis:
30+
> **Disclaimer**:
31+
> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance.
32+
> While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
4333
44-
- Determine if the IAM user or automation pipeline routinely performs privileged actions using temporary session tokens.
45-
- Validate whether the MFA context and source IP match expected developer or CI/CD behavior.
46-
- Review recent IAM policy changes or deployments that may explain the behavior.
47-
- Confirm if the user has a legitimate reason to perform sensitive IAM operations with temporary credentials, such as during a deployment or maintenance window.
48-
49-
### Response and remediation:
34+
### Investigating AWS IAM API Calls via Temporary Session Tokens
5035
51-
- Revoke the temporary session token and rotate long-term access keys for the associated user if the behavior is unauthorized.
52-
- Audit related CloudTrail events within the same session to identify policy changes, resource creation, or lateral movement.
53-
- Add explicit deny statements in IAM policies to prevent sensitive IAM actions when aws:authType is not "console".
54-
- Implement IP restrictions for IAM and STS API actions using aws:SourceIp conditions.
55-
- Strengthen monitoring for IAM activity initiated by session tokens with MFA to improve detection coverage.
36+
Temporary session credentials in AWS (identified by access keys beginning with "ASIA") are typically short-lived tokens
37+
issued by the AWS Security Token Service (STS). While they are legitimate and often used by developers or automation pipelines,
38+
their use in direct IAM management or privilege modification is highly unusual and may indicate credential misuse.
39+
40+
Attackers who compromise IAM users, roles, or federated identities can obtain session tokens to blend in with normal operations.
41+
They may then execute sensitive IAM API actions such as `CreateAccessKey`, `PutUserPolicy`, or `UpdateAssumeRolePolicy` to
42+
establish persistence, escalate privileges, or disable protections.
43+
44+
#### Possible investigation steps
45+
46+
- **Identify the actor**
47+
- Review `aws.cloudtrail.user_identity.arn` and `aws.cloudtrail.user_identity.type` to determine the originating user or role.
48+
- Check `event.original` if ingested, look for `sessionCredentialFromConsole: true`. If this is present, the temporary session token was created as part of a legitimate console login session and this alert can be ignored.
49+
- Examine `aws.cloudtrail.user_identity.session_context.mfa_authenticated` — absence of MFA may indicate token misuse.
50+
51+
- **Analyze the API context**
52+
- Review `event.action` and `aws.cloudtrail.request_parameters` for the exact IAM operation performed.
53+
- Identify whether the action modifies roles, user policies, trust relationships, or credentials.
54+
- Determine if this session token was associated with prior `sts:GetSessionToken`, `sts:AssumeRole`, or `AWS SSO` events.
55+
56+
- **Evaluate source and behavior**
57+
- Inspect `source.ip` and `user_agent.original` for unexpected origins or tools.
58+
- Check if the request came from known infrastructure (e.g., CI/CD nodes, bastion hosts) or an anomalous network.
59+
- Compare `@timestamp` against normal operating hours or deployment schedules.
60+
61+
- **Correlate related activity**
62+
- Look for subsequent or preceding activity using the same access key:
63+
- IAM changes (`CreateUser`, `AttachUserPolicy`, `EnableMFADevice`)
64+
- STS operations (`AssumeRole`, `GetCallerIdentity`)
65+
- CloudTrail or GuardDuty configuration changes (possible defense evasion)
66+
- If applicable, search for multiple users exhibiting similar patterns, a sign of large-scale token misuse.
67+
68+
### False positive analysis
69+
70+
- **Expected automation**
71+
- Some CI/CD pipelines, monitoring tools, or AWS SDK-based automation may perform IAM operations using temporary credentials.
72+
- Validate whether the IAM user or assumed role performing these actions belongs to an authorized automation workflow.
73+
- **Administrative operations**
74+
- Security or DevOps engineers may temporarily use session credentials for maintenance or testing.
75+
- Cross-reference with recent change tickets or known operations schedules.
76+
- **Federated identity scenarios**
77+
- Federated logins (via AWS SSO or external IdPs) can also generate temporary "ASIA" credentials. Verify if the source identity
78+
aligns with expected roles or groups.
79+
- **Console Login Session**
80+
- Console login sessions result in temporary "ASIA" credentials and can typically be ignored for this alert. This can be verified in `event.original` as `sessionCredentialFromConsole: true`
81+
82+
### Response and remediation
83+
84+
- **Containment**
85+
- If activity is unauthorized, immediately revoke the temporary session by invalidating the associated IAM credentials.
86+
- Rotate long-term credentials (access keys, passwords) for the parent IAM user or role.
87+
88+
- **Investigation**
89+
- Search for all actions linked to the same `access_key_id` to assess potential persistence or lateral movement.
90+
- Examine the creation of new users, keys, or policies during or shortly after the detected session.
91+
92+
- **Recovery and hardening**
93+
- Require MFA for all privileged actions using `aws:MultiFactorAuthPresent` conditions.
94+
- Implement detection coverage for follow-on persistence actions such as:
95+
- `iam:CreateAccessKey`
96+
- `iam:PutUserPolicy`
97+
- `iam:UpdateAssumeRolePolicy`
98+
- Educate administrative users and developers on secure token handling and the risks of shared credential reuse.
99+
100+
### Additional information
101+
102+
For more information on detecting and mitigating session token abuse:
103+
- **[AWS Security Token Service (STS) Documentation](https://docs.aws.amazon.com/STS/latest/APIReference/Welcome.html)**
104+
- **[AWS IR Playbooks](https://github.com/aws-samples/aws-incident-response-playbooks/blob/c151b0dc091755fffd4d662a8f29e2f6794da52c/playbooks/)**
105+
- **[AWS Customer Playbook Framework](https://github.com/aws-samples/aws-customer-playbook-framework/tree/a8c7b313636b406a375952ac00b2d68e89a991f2/docs)**
106+
- **Security Best Practices:** [AWS Knowledge Center – Security Best Practices](https://aws.amazon.com/premiumsupport/knowledge-center/security-best-practices/).
56107
"""
57-
58108
references = ["https://www.sygnia.co/blog/sygnia-investigation-bybit-hack/"]
59109
risk_score = 21
60110
rule_id = "c70d9f0d-8cb6-4cfc-85df-a95c1ccf4eab"
@@ -68,7 +118,7 @@ tags = [
68118
"Data Source: AWS STS",
69119
"Tactic: Persistence",
70120
"Tactic: Privilege Escalation",
71-
"Resources: Investigation Guide"
121+
"Resources: Investigation Guide",
72122
]
73123
timestamp_override = "event.ingested"
74124
type = "new_terms"
@@ -79,8 +129,24 @@ event.dataset: aws.cloudtrail
79129
and event.outcome: "success"
80130
and aws.cloudtrail.user_identity.type: "IAMUser"
81131
and aws.cloudtrail.user_identity.access_key_id: ASIA*
132+
and source.ip: *
133+
and not user_agent.original : "AWS Internal"
82134
'''
83135

136+
137+
[[rule.threat]]
138+
framework = "MITRE ATT&CK"
139+
[[rule.threat.technique]]
140+
id = "T1098"
141+
name = "Account Manipulation"
142+
reference = "https://attack.mitre.org/techniques/T1098/"
143+
144+
145+
[rule.threat.tactic]
146+
id = "TA0003"
147+
name = "Persistence"
148+
reference = "https://attack.mitre.org/tactics/TA0003/"
149+
84150
[rule.investigation_fields]
85151
field_names = [
86152
"@timestamp",
@@ -94,25 +160,14 @@ field_names = [
94160
"event.outcome",
95161
"cloud.account.id",
96162
"cloud.region",
97-
"aws.cloudtrail.request_parameters"
163+
"aws.cloudtrail.request_parameters",
98164
]
99165

100-
[[rule.threat]]
101-
framework = "MITRE ATT&CK"
102-
103-
[[rule.threat.technique]]
104-
id = "T1098"
105-
name = "Account Manipulation"
106-
reference = "https://attack.mitre.org/techniques/T1098/"
107-
108-
[rule.threat.tactic]
109-
id = "TA0003"
110-
name = "Persistence"
111-
reference = "https://attack.mitre.org/tactics/TA0003/"
112-
113166
[rule.new_terms]
114167
field = "new_terms_fields"
115168
value = ["aws.cloudtrail.user_identity.arn"]
116169
[[rule.new_terms.history_window_start]]
117170
field = "history_window_start"
118171
value = "now-14d"
172+
173+

0 commit comments

Comments
 (0)