Join our Newsletter — 33% off our NHI Course
Home› Guides› How to trace an AWS assumed-role session back…
Guide Cloud & Workload Identity

How to trace an AWS assumed-role session back to the person or workload behind it: follow the CloudTrail chain to a real actor

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 20 November 2026 16 min read
On this page

When a CloudTrail event says an assumed role did something, the real question is who or what was holding that role session, and AWS records enough to answer it if you know which fields to join. An assumed-role ARN names a role and a session name, not a person. Once sessions are chained, with one role assuming another, the original caller can sit two or three hops back, in a different account, behind a federated sign-in. This guide walks through the fields that matter, the join that links an AssumeRole call to the actions taken with its credentials, how to follow a chain hop by hop, and how to use source identity so that the next investigation takes minutes rather than days.

It assumes you already understand how AWS STS issues temporary credentials. For the background on roles, trust policies and session policies, read the AWS STS and AssumeRole Guide. This page is only about attribution: getting from an action back to an actor.

Key takeaways

  • An assumed-role event identifies the role and the session name. According to AWS, later calls made through AssumeRole identify the role only, not the user, so attribution needs the AssumeRole event that created the session.
  • The join key is the temporary access key ID. The AssumeRole event records it in responseElements.credentials.accessKeyId, and every later action signed with those credentials carries it in userIdentity.accessKeyId.
  • Cross-account AssumeRole calls are logged in both accounts with a shared sharedEventID, which links the caller's record to the target account's record.
  • Role chaining repeats the problem at each hop, so you walk backwards one AssumeRole event at a time until you reach an IAM user, a federated sign-in or a workload.
  • Source identity is the fix. Once set, AWS says it persists through role chaining and cannot be changed during the session, and it appears on every later event as userIdentity.sessionContext.sourceIdentity.
  • Session names help but are not a control on their own: AWS documents source identity, not the session name, as the value that is immutable and survives chaining.

Why assumed-role sessions hide the actor

Roles are designed to be shared. A single deployment role may be assumed by a CI pipeline, three engineers and an incident break-glass process. Every one of them produces CloudTrail events whose userIdentity.type is AssumedRole and whose ARN takes the form arn:aws:sts::123456789012:assumed-role/RoleName/SessionName. The role name tells you what permissions were used. It does not tell you whose decision it was.

AWS's own description of IAM CloudTrail logging makes the point directly: subsequent calls by an IAM user through AssumeRole carry role identity only, with no user. The person is traceable only through source identity, which appears in the session context on later calls, and through the session name chosen when the role was assumed.

Three situations make this harder:

  • Role chaining. AWS defines role chaining as using a role to assume a second role. Each hop creates a new session with its own temporary key, so the action you are investigating may be signed by the third key in a sequence.
  • Cross-account access. The AssumeRole call is logged in the account that owns the role and in the caller's account. If you only collect logs from one account, half of the chain is missing.
  • Federation. AssumeRoleWithSAML and AssumeRoleWithWebIdentity calls can be unauthenticated from AWS's point of view, so AWS notes that the caller's account has no entry. The identity lives in the identity provider's assertion or token, as recorded in the target account's event.

Attackers who obtain role credentials benefit from this ambiguity. Using stolen credentials that look like normal role activity maps to MITRE ATT&CK: Valid Accounts: Cloud Accounts (T1078.004). The faster you can name the actor behind a session, the faster you can tell a mistake by a colleague from an intrusion.

The CloudTrail fields that matter

The CloudTrail userIdentity element is documented in the AWS CloudTrail user guide. For attribution work these are the fields to extract on every event you touch.

FieldWhat AWS says it holdsWhy it matters for attribution
userIdentity.typeThe identity type, for example IAMUser, AssumedRole, FederatedUser, AWSService, IdentityCenterUser; STS federation adds SAMLUser and WebIdentityUserTells you whether you have reached a long-lived principal or are still inside a session
userIdentity.principalIdFor an assumed role, the role's unique ID, a colon, and the session nameStable role identifier plus the session label
userIdentity.arnThe principal that made the call, in assumed-role/Role/Session form for sessionsHuman-readable role and session name
userIdentity.accessKeyIdThe access key ID used to sign the request; may be absent or emptyThe join key back to the AssumeRole event
sessionContext.sessionIssuerType, user name, principal ID, ARN and account of the entity that issued the sessionNames the role whose session this is
sessionContext.attributescreationDate and mfaAuthenticatedWhen the session started and whether MFA was used to obtain it
sessionContext.sourceIdentityThe original user identity, when configured in AWS STSThe answer, if you have enabled it
sessionContext.webIdFederationDataThe federated provider and the attributes it reportedIdentifies web identity sessions
sessionContext.ec2RoleDelivery1.0 for IMDSv1 or 2.0 for IMDSv2Shows the credentials came from an instance profile
userIdentity.invokedByThe AWS service that made the requestSeparates service-driven calls from direct ones
userIdentity.onBehalfOfUser ID and identity store ARN for IAM Identity Center or AWS Builder ID callersPoints at the workforce identity in the identity store

On the AssumeRole event itself, the fields that matter are requestParameters.roleArn, requestParameters.roleSessionName, requestParameters.sourceIdentity, responseElements.credentials.accessKeyId, responseElements.assumedRoleUser.arn and sharedEventID. AWS states that CloudTrail includes the full response elements for AssumeRole except the secret access key, and that AssumeRole is logged as a read-only event even though its response elements are kept. If your trail or your SIEM filter drops read-only management events, you have dropped the events this whole method depends on.

The core join: from an action back to its AssumeRole call

Every role session has its own temporary access key ID. AWS's examples show these keys beginning with ASIA. The AssumeRole call that created the session returns that key ID in its response, and CloudTrail records it. Every action signed with the session's credentials carries the same key ID in userIdentity.accessKeyId. That is the join.

  1. Start from the suspicious event. Record eventTime, userIdentity.arn, userIdentity.accessKeyId, sessionContext.attributes.creationDate and recipientAccountId.
  2. Search the account that owns the role for eventName = AssumeRole (or AssumeRoleWithSAML, AssumeRoleWithWebIdentity) where responseElements.credentials.accessKeyId equals the key you recorded. Narrow the time window to just before the session creation date.
  3. Read the userIdentity block of that AssumeRole event. That is the principal that asked for the session: an IAM user, another assumed role, a SAML user, a web identity user or an AWS service.
  4. If the caller was another assumed role, repeat from step 1 using the caller's access key ID. If the caller was in another account, switch to that account's logs and use sharedEventID to find its copy of the record.
  5. Stop when you reach a principal that is not a session: an IAM user with a long-lived key, a federated sign-in whose assertion names a person, an IAM Identity Center user, or a workload whose credentials came from a known source such as an instance profile.

The reverse direction is just as useful during containment. Once you know which AssumeRole call issued a session, search for every event carrying that temporary key to list everything the session did.

An illustrative query over raw CloudTrail files, adapted from the pattern in AWS's examples:

zcat *.json.gz | jq -r '.Records[] | select(.userIdentity.accessKeyId == "ASIAEXAMPLEKEY") | [.eventTime, .eventName, .userIdentity.arn] | @tsv'

And the backward step, also illustrative:

zcat *.json.gz | jq -r '.Records[] | select(.eventName | startswith("AssumeRole")) | select(.responseElements.credentials.accessKeyId == "ASIAEXAMPLEKEY") | [.eventTime, .userIdentity.type, .userIdentity.arn, .requestParameters.roleSessionName, .sourceIPAddress] | @tsv'

The same logic translates directly to Athena over a CloudTrail table, CloudTrail Lake or any SIEM that parses CloudTrail JSON. Field names stay the same; only the query syntax changes. For more general CloudTrail investigation technique, including scoping a compromised long-lived key, see How to Investigate CloudTrail for a Compromised Access Key.

Walking a role chain hop by hop

Role chaining is where most investigations stall, usually because each hop's events live in a different account or a different log store. A disciplined approach keeps a small table as you go, one row per hop.

HopAccountSession ARNTemporary keyCaller found in AssumeRole eventSource identity
3 (the action)Productionassumed-role/DataAdmin/ops-sessionASIA...Cassumed-role/DeployRole/pipeline-runRecorded or empty
2Toolingassumed-role/DeployRole/pipeline-runASIA...BWebIdentityUser via OIDC providerRecorded or empty
1ToolingWeb identity federationASIA...AToken subject from the CI providerRecorded or empty

The example values are illustrative. The point is the discipline: each row is populated from one AssumeRole event, and each next row starts from that event's caller.

Several facts from AWS's documentation shape how chains behave:

  • Chained sessions are short. AWS says role chaining limits a role session to a maximum of one hour regardless of the role's configured maximum, and that a chained AssumeRole requesting more than one hour fails. If you see activity from one chained session spread over several hours, you are looking at several sessions, each with its own AssumeRole event and its own key.
  • Cross-account calls appear twice. In the caller's account, the AssumeRole record carries the caller's full identity. In the role's account, AWS shows the caller as type AWSAccount with the caller's account ID and principal ID. Both records share requestID, sharedEventID and eventID. Use sharedEventID to jump between them.
  • Denied attempts may be missing. AWS states that denied cross-account AssumeRole requests are not logged in the target account. Look for failed attempts in the caller's account instead.
  • Global endpoint events land in one Region. AWS notes that requests to the global STS endpoint are logged in us-east-1, with additionalEventData.RequestDetails showing the endpoint type and serving Region. If you collect CloudTrail per Region, make sure us-east-1 is included.
  • Transitive session tags carry forward. AWS says tags marked transitive pass to all later sessions in a role chain. If you use tags to label teams or workloads, they can survive the chain, though tags are an access-control feature, not an audit guarantee.

Organisation-wide trails make this tractable. If each account keeps its own trail with its own retention, walking a chain means requesting logs from several teams, and the trail you need may already have rolled over. Centralise CloudTrail for every account and every Region before you need it. The AWS CloudTrail Guide covers trail design, and How to detect attackers disabling cloud audit logging covers protecting it.

Reaching the end of the chain: people, federation and workloads

The last hop is where you finally name an actor. What that looks like depends on how the first session was created.

IAM users

If the first AssumeRole caller is an IAMUser, the event shows the user name, ARN and the long-lived access key used. You now have a named principal. Whether that principal maps to a person or to a shared automation account is an inventory question, not a CloudTrail one. AWS's cross-account example also shows requestParameters.serialNumber where MFA was presented on the AssumeRole call.

SAML federation

For AssumeRoleWithSAML, AWS documents the user identity type SAMLUser, with user name and identity provider, plus request parameters including the SAML assertion ID and session name, and response elements including the subject, subject type, issuer and audience. The subject is what you hand to your identity provider team. Their sign-in logs, matched by assertion ID or time and subject, tell you which person authenticated and from where.

Web identity and OIDC

For AssumeRoleWithWebIdentity, AWS documents the type WebIdentityUser, the OIDC provider ARN, and response elements including subjectFromWebIdentityToken, provider and audience. For CI pipelines and Kubernetes workloads federating into AWS, the token subject usually encodes the repository, branch, environment or service account. That is your workload identity, and it should match an entry in your workload inventory.

IAM Identity Center

For workforce access through IAM Identity Center, the onBehalfOf object carries the user ID and identity store ARN. Resolve that user ID in the identity store to get the person.

Instance profiles and services

Where sessionContext.ec2RoleDelivery is present, the credentials came from the instance metadata service, and the value shows whether IMDSv1 or IMDSv2 was used. The actor is whatever runs on that instance, so the next step is host-level evidence. If the same instance role key appears from an unexpected sourceIPAddress, treat it as possible credential theft from metadata, which maps to MITRE ATT&CK: Cloud Instance Metadata API. Where invokedBy names an AWS service, the service acted for someone, and you trace the configuration or the principal that triggered it instead.

Making the next trace easy with source identity

Everything above is reconstruction. Source identity turns it into a lookup. AWS describes it as a custom string identifying the person or application performing actions with an assumed role session, stored in CloudTrail so that administrators can determine who or what performed actions. AWS recommends it for controlling which identity assumes a role and for mining CloudTrail to find who used a role.

The properties that make it suitable for attribution, as documented by AWS:

  • It persists through role chaining. Once set, the value appears in requests for any action during the session and carries into chained sessions.
  • It cannot be changed. If a chained session tries to set a different value, the request is denied.
  • It is visible in two places. On the AssumeRole event as requestParameters.sourceIdentity, and on every later action as userIdentity.sessionContext.sourceIdentity.
  • It is constrained. Values are 2 to 256 characters of alphanumerics, underscores and . , + = @ -, and cannot begin with aws:.

How to set it

  • AssumeRole: pass the SourceIdentity API parameter or the CLI --source-identity option.
  • SAML: include the attribute https://aws.amazon.com/SAML/Attributes/SourceIdentity in the assertion, typically mapped to the user's directory name.
  • OIDC: include the claim https://aws.amazon.com/source_identity in the token.

Permissions and enforcement

The principal needs sts:SetSourceIdentity. AWS states that for role chaining this permission is required in both the caller's permissions policy and the target role's trust policy, and that cross-account it must appear in the originating account's permissions policy and the target account's trust policy. AWS also states that trust policies for roles connected to an identity provider must include sts:SetSourceIdentity or the AssumeRole call fails, so plan the trust policy change before you configure the attribute at the identity provider.

Two condition keys make it enforceable. sts:SourceIdentity is present when the value is first set and can restrict which values are allowed. aws:SourceIdentity is present on all later requests in the session, including role-chaining requests. A trust policy on a sensitive role that requires aws:SourceIdentity to be present stops anonymous chained sessions reaching it.

Known gaps

AWS lists two limitations. Source identity is not captured in CloudTrail when an AWS service or service-linked role acts on behalf of a federated or workforce identity. And you cannot switch in the console to a role that requires a source identity; you must use the CLI or API with the parameter. Plan for both: keep the session-name join for service-driven activity, and decide which roles are console-accessible before making source identity mandatory on them.

Session names as a supplement

The role session name appears in the assumed-role ARN and in requestParameters.roleSessionName, and the sts:RoleSessionName condition key can require a specific value in the trust policy. It is useful for labelling, for example a pipeline run ID or a ticket number. AWS does not describe session names as immutable or as persisting through chaining, which is why source identity, not the session name, should be your attribution control.

Common failure patterns

  • Read-only events filtered out. AssumeRole is logged as read-only. Pipelines that drop read-only management events to save cost remove the only record of who created each session.
  • Per-account trails with short retention. The chain crosses accounts and the earliest hop rolled off weeks ago.
  • us-east-1 not collected. Global STS endpoint calls are logged there, so chains that start with a global-endpoint call look like they start from nowhere.
  • Generic session names. Every pipeline uses the same session name, so the ARN tells you nothing and you rely entirely on the key join.
  • Source identity set on some roles only. The first hop sets it, the attacker's path goes through a role that never required it, and the value is missing exactly where you need it. Require it with conditions on sensitive roles.
  • Treating the role owner as the actor. The team that owns a role is not necessarily the principal that assumed it. Always trace to the AssumeRole caller.
  • Stopping at the identity provider boundary. A SAML subject or OIDC token subject is evidence, not an answer, until the identity provider or CI logs confirm who authenticated.

Practitioner checklist

  • Confirm an organisation-wide CloudTrail trail covers every account and every Region, including us-east-1, with management read events kept.
  • Keep CloudTrail long enough to walk a chain back to its first hop; align retention with your incident investigation window.
  • Build a saved query that, given a temporary access key ID, returns the AssumeRole event that issued it and every action signed with it.
  • Index sharedEventID in your SIEM so cross-account AssumeRole records can be joined in one step.
  • Configure source identity at your identity provider (SAML attribute or OIDC claim) and in automation that calls AssumeRole directly.
  • Add sts:SetSourceIdentity to the trust policies of roles connected to your identity provider before enabling the attribute.
  • On sensitive roles, require aws:SourceIdentity in the trust policy so chained sessions without it are refused.
  • Set meaningful session names in pipelines (run ID, repository, ticket) and constrain them with sts:RoleSessionName where useful.
  • Maintain an inventory mapping OIDC token subjects and instance profiles to owning teams and workloads.
  • Rehearse a trace in a tabletop exercise: pick an assumed-role event and time how long it takes to name the actor.

Standards and references

Related NHI Mgmt Group resources: AWS STS and AssumeRole Guide · AWS CloudTrail Guide · How to Investigate CloudTrail for a Compromised Access Key · How to detect attackers disabling cloud audit logging

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.