AWS IAM API Calls via Temporary Session Tokens
Description
Detects sensitive AWS IAM API operations executed using temporary session credentials (access key IDs beginning with "ASIA"). Temporary credentials are commonly issued through sts:GetSessionToken, sts:AssumeRole, or AWS SSO logins and are meant for short-term use. It is unusual for legitimate users or automated processes to perform privileged IAM actions (e.g., creating users, updating policies, or enabling/disabling MFA) with session tokens. This behavior may indicate credential theft, session hijacking, or the abuse of a privileged role’s temporary credentials.
Query · kuery
data_stream.dataset: aws.cloudtrail
and event.provider: ("iam.amazonaws.com")
and event.outcome: "success"
and aws.cloudtrail.user_identity.type: "IAMUser"
and aws.cloudtrail.user_identity.access_key_id: ASIA*
and source.ip: *
and not user_agent.original : "AWS Internal"
and not aws.cloudtrail.session_credential_from_console: true
Investigation fields
Pivot points the source recommends for triage.
@timestampuser.nameuser_agent.originalsource.ipaws.cloudtrail.user_identity.arnaws.cloudtrail.user_identity.typeaws.cloudtrail.user_identity.access_key_idevent.actionevent.outcomecloud.account.idcloud.regionaws.cloudtrail.request_parameters
Known false positives
- Some CI/CD pipelines or administrative users may use session tokens. Review user context, IP, and timing to validate. This rule automatically excludes console login sessions using the aws.cloudtrail.session_credential_from_console field, which significantly reduces false positives from legitimate console-based IAM operations.
Analyst notes
Investigating AWS IAM API Calls via Temporary Session Tokens
Temporary session credentials in AWS (identified by access keys beginning with "ASIA") are typically short-lived tokens issued by the AWS Security Token Service (STS). While they are legitimate and often used by developers or automation pipelines, their use in direct IAM management or privilege modification is highly unusual and may indicate credential misuse.
Attackers who compromise IAM users, roles, or federated identities can obtain session tokens to blend in with normal operations.
They may then execute sensitive IAM API actions such as CreateAccessKey, PutUserPolicy, or UpdateAssumeRolePolicy to
establish persistence, escalate privileges, or disable protections.
Possible investigation steps
- Identify the actor
- Review
aws.cloudtrail.user_identity.arnandaws.cloudtrail.user_identity.typeto determine the originating user or role. - This rule automatically filters out console login sessions using
aws.cloudtrail.session_credential_from_console, so alerts indicate non-console temporary credential usage. -
Examine
aws.cloudtrail.user_identity.session_context.mfa_authenticated— absence of MFA may indicate token misuse. -
Analyze the API context
- Review
event.actionandaws.cloudtrail.request_parametersfor the exact IAM operation performed. - Identify whether the action modifies roles, user policies, trust relationships, or credentials.
-
Determine if this session token was associated with prior
sts:GetSessionToken,sts:AssumeRole, orAWS SSOevents. -
Evaluate source and behavior
- Inspect
source.ipanduser_agent.originalfor unexpected origins or tools. - Check if the request came from known infrastructure (e.g., CI/CD nodes, bastion hosts) or an anomalous network.
-
Compare
@timestampagainst normal operating hours or deployment schedules. -
Correlate related activity
- Look for subsequent or preceding activity using the same access key:
- IAM changes (
CreateUser,AttachUserPolicy,EnableMFADevice) - STS operations (
AssumeRole,GetCallerIdentity) - CloudTrail or GuardDuty configuration changes (possible defense evasion)
- IAM changes (
- If applicable, search for multiple users exhibiting similar patterns, a sign of large-scale token misuse.
False positive analysis
- Expected automation
- Some CI/CD pipelines, monitoring tools, or AWS SDK-based automation may perform IAM operations using temporary credentials.
- Validate whether the IAM user or assumed role performing these actions belongs to an authorized automation workflow.
- Administrative operations
- Security or DevOps engineers may temporarily use session credentials for maintenance or testing.
- Cross-reference with recent change tickets or known operations schedules.
- Federated identity scenarios
- Federated logins (via AWS SSO or external IdPs) can also generate temporary "ASIA" credentials. Verify if the source identity aligns with expected roles or groups.
- Console Login Session
- Console login sessions are automatically filtered out by this rule using the
aws.cloudtrail.session_credential_from_consolefield.
Response and remediation
- Containment
- If activity is unauthorized, immediately revoke the temporary session by invalidating the associated IAM credentials.
-
Rotate long-term credentials (access keys, passwords) for the parent IAM user or role.
-
Investigation
- Search for all actions linked to the same
access_key_idto assess potential persistence or lateral movement. -
Examine the creation of new users, keys, or policies during or shortly after the detected session.
-
Recovery and hardening
- Require MFA for all privileged actions using
aws:MultiFactorAuthPresentconditions. - Implement detection coverage for follow-on persistence actions such as:
iam:CreateAccessKeyiam:PutUserPolicyiam:UpdateAssumeRolePolicy
- Educate administrative users and developers on secure token handling and the risks of shared credential reuse.
Additional information
For more information on detecting and mitigating session token abuse: - AWS Security Token Service (STS) Documentation - AWS IR Playbooks - AWS Customer Playbook Framework - Security Best Practices: AWS Knowledge Center – Security Best Practices.