Agent attribution via Trusted Identity Propagation
Five years ago I posted a request for better OIDC claim handing in AWS IAM federation. AWS's recently-launched enhanced trusted identity propagation is even better than what I asked for. The CI/CD example in their blog post is valuable, but I wanted to expand on their risk score example. In this blog I show how TIP can be used for AI agent attribution in CloudTrail.
AI agents can take many forms: some run in cloud sandboxes on-demand, some run in a loop in AgentCore and some run on engineers' laptops on their behalf. This blog post is specifically about the latter type, and how we (as AWS organisation administrators) can distinguish between AWS activity caused by an engineer vs activity caused by an agent running on that engineer's laptop. I've created a demo project that shows how this can be achived. But first, lets talk through the problem.
Problem statement¶
There are three parts to this problem:
- How to determine that activity is triggered by an agent
- How to verifiably attest to a remote identity provider the answer to the above
- How to inject that context into CloudTrail
The launch of trusted identity propagation solves the third problem. All we need is an IdP to add claims to its OIDC token that indicate whether it's for a human or an agent, which agent, and which agent session it was on behalf of, if any.
The first part of the problem is also reasonably easy to solve. AI agents are
generally not malicious and don't try to hide their existence - quite the
opposite, in fact. They leave a veritable treasure trove of contextual information
in environment variables when launching tools. In fact, agents don't just identify
themselves, they provide context on what they were doing: Amp sets AMP_THREAD_ID,
Claude Code sets CLAUDE_CODE_SESSION_ID, Codex sets CODEX_THREAD_ID, etc.
These are insanely useful for later on attributing specific events (e.g. an S3
bucket that went missing) to a specific agent thread - especially if your company
is using a tool as great as Amp.
So really the trickiest part is tying these two ends of the problem together, which is the second part of the problem described above. And conveniently enough this got a whole lot easier this year with the launch of macOS 27. macOS 27 launched App Attest, which provides a mechanism by which an application running on macOS can create an assertion blob that can be sent to your backend, and that blob can be cryptographically verified as having come from an untampered copy of your application.
It can take a moment to realise what this allows. Usually there's no point in
trying to detect an agent's presence, because the agent could just subvert your
credential_process's logic and provide a fake answer. But App Attest means
you can verify that a request came from your app and nowhere else. That means
you can trust code running in an somewhat untrusted environment. You can also
write IAM policies that allow a role access to files in an S3 bucket when
those requests are lovingly hand-crafted by a human, but deny it when those
same requests are issued by an agent on the human's behalf.
Implementation¶
You can look at the code, but note that it was entirely AI-generated and I haven't reviewed it closely. The intention of this blog post is to show what is now possible. I have erred on the side of simplicity and as little code as possible to demonstrate the idea, rather than robust production-grade code. That said, there are still some interesting building blocks in there that I will call out.
- The IdP itself runs as a Lambda Web Function, which automatically replicates across multiple regions.
- The IdP's OIDC tokens are signed by a multi-region AWS KMS key, using RSA-2048.
- The Lambda Web Function requires IAM authentication. It sits behind CloudFront, which uses OAC to authenticate to it. So it's robust to an entire AWS region going down.
- The CloudFront distribution authenticates the CLI using mTLS. The CLI's mTLS private key is stored in the Mac's Secure Enclave. This key can't be accessed by any application other than the code-signed CLI.
- Credentials cached on-disk are encrypted using another key stored in the Secure Enclave, so agents can't just read cached credentials. The role ARN and the results of agent detection form part of the AEAD encryption context.
- AI agent detection is best-effort. A particularly malicious agent could launch a tool with a clean environment, and reparent the child process. This example is not intended to prevent that. Engineer laptops are a semi-trusted environment anyway. This is is designed more for improving operations, rather than locking things down.
EDIT: I forgot the obligatory CloudTrail JSON that is a hallmark of about 30% of my blog posts. Here's what an event in CloudTrail looks like when a laptop uses this tool to authenticate to AWS:
{
"userIdentity": {
"type": "AssumedRole",
"principalId": "AROA45JVDZBV6VPLJ4YG3:aidan@amp",
"arn": "arn:aws:sts::887559014507:assumed-role/agent-creds-demo/aidan@amp",
"accountId": "887559014507",
"sessionContext": {
"sessionIssuer": {
"type": "Role",
"arn": "arn:aws:iam::887559014507:role/agent-creds-demo",
"userName": "agent-creds-demo"
},
"webIdFederationData": {
"federatedProvider": "arn:aws:iam::887559014507:oidc-provider/issuer.agent-creds.mumululu.xyz",
"attributes": {}
},
"attributes": { "creationDate": "2026-12-01T11:22:44Z", "mfaAuthenticated": "false" }
},
"onBehalfOf": {
"federatedProviderArn": "arn:aws:iam::887559014507:oidc-provider/issuer.agent-creds.mumululu.xyz",
"subject": "aidan",
"subjectType": "user",
"issuer": "issuer.agent-creds.mumululu.xyz"
},
"transactionContext": {
"IdentityProvider": {
"agent": "amp",
"agent_session": "T-01a23088-452b-732d-aa36-8e4103be2f0d",
"device_serial": "J67WRH06T2",
"agent_evidence": "env"
}
}
},
"eventTime": "2026-12-01T11:22:45Z",
"eventSource": "sts.amazonaws.com",
"eventName": "GetCallerIdentity",
"awsRegion": "us-east-1",
"sourceIPAddress": "103.138.244.98",
"userAgent": "aws-cli/2.42.7 ... md/command#sts.get-caller-identity",
"eventType": "AwsApiCall",
"recipientAccountId": "887559014507"
}
Where to from here?¶
This isn't even touching sts:GetScopedCredentials, which also launched
last week and is extremely relevant to limiting agents' access to stuff in the
cloud. Expect a blog post about that soon.
This also doesn't address the value of Touch ID. This credential_process could absolutely be extended to only vend credentials for sensitive roles to an agent when a human confirms as much by using Touch ID per request. Or instead of per-request, it could be per role per process lifetime. The possibilities are endless. Maybe I'll add that to the demo next.
I would have loved for this demo to make use of IAM Identity Center instead of my homebrewed IdP, but that's not possible. Identity Center does allow trusted token issuers to access IAM roles on behalf of people (see my other post), but those tokens can't yet be configured to be used for TIP. I'm sure it's coming soon.