Skip to main content

Two pods, one role, one allowed SPIFFE ID

· 8 min read
Abdulmalik
AppSec Engineer

Two pods can share one IAM role, and one S3 bucket policy can still allow the first pod and deny the second. The tool is a SPIFFE ID that AWS now adds to the IAM role session on EKS Pod Identity. The bucket policy matches that ID. The role stays the same.

This feature is in preview as of 1 December 2026. AWS can still change it. I have not run it on a cluster yet, so the test result in this post is a placeholder that I will fill in after I run it.

Related:

The question the role cannot answer​

An IAM role says what a caller can do. It does not say which workload is the caller. If two pods use one role, the bucket sees one principal. A deny rule on the role denies both pods, and an allow rule on the role allows both.

My 25 November post fixed a different problem. It limited what the role can reach with S3 Files access points and GetScopedCredentials. This post covers the next question. When two pods hold the same role, which pod made the call?

What the identity is​

AWS adds the identity to the role session. It does not replace the role. The role defines what the workload can do. The identity says which workload uses the role. On EKS, the Pod Identity agent delivers the credentials. AWS says the standard Pod Identity credentials carry the identity, so the AWS SDKs need no code change.

The identity is a SPIFFE ID (a standard name for a workload, written as a URI). AWS issues it only after EKS attests facts about the pod. Attest means that EKS proves the facts and the pod does not claim them. EKS attests the cluster name, the namespace, the service account, the pod name, the pod UID, and the node name.

The default template builds the ID from the Region, the cluster name, the namespace, and the service account. The path pattern looks like this:

{aws:RequestedRegion}/eks/{ClusterName}/ns/{Namespace}/sa/{ServiceAccount}

The trust domain in front of that path comes from the provider that you create. The default template works at the service account level. Every pod under one service account gets the same ID. So two workloads need two service accounts. Each service account needs its own Pod Identity association with the workload identity setting turned on. Both associations can point at the same role.

The bucket policy​

The policy below allows one workload to read objects. I wrote it from the shape that AWS shows in the getting-started guide. The ID is a placeholder on purpose. The AWS pages show the trust domain in different ways, for example 111122223333.aws.internal in one example and payments-prod.111122223333.aws.internal in another. I do not copy one of them as fact.

To get the real value, run the workload once. Open the AssumeRole event for the role in CloudTrail. The field userIdentity.onBehalfOf shows the subject and the issuer. Copy both into the policy.

Hand-drawn diagram titled Same role, different SPIFFE ID. Pod A with service account checkout-sa and pod B with service account reports-sa both use one IAM role. Each pod gets a session with its own SPIFFE ID. The S3 bucket policy allows only the session whose aws:OriginIdentity/Subject matches the checkout-sa ID. Pod A reaches the S3 bucket. Pod B stops at AccessDenied.

Both pods use one role. The bucket policy allows only the session with the checkout-sa ID. Pod B gets AccessDenied.

{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowCheckoutWorkload",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::BUCKET/*",
"Condition": {
"StringEquals": {
"aws:PrincipalAccount": "ACCOUNT_ID",
"aws:OriginIdentity/Subject": "<RENDERED_SPIFFE_ID_FROM_YOUR_ACCOUNT>",
"aws:OriginIdentity/Issuer": "arn:aws:iam::ACCOUNT_ID:workload-identity-provider/PROVIDER_NAME"
}
}
},
{
"Sid": "DenyOtherWorkloads",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::BUCKET/*",
"Condition": {
"StringNotEquals": {
"aws:OriginIdentity/Subject": "<RENDERED_SPIFFE_ID_FROM_YOUR_ACCOUNT>"
}
}
}
]
}

I match both condition keys. AWS says that an ID is unique only within its provider, so the issuer must match too. The aws:PrincipalAccount condition is there because S3 Block Public Access rejects a policy with "Principal": "*" unless a condition limits it.

The deny statement hits every other principal, including administrators. Use a test bucket first. You can still edit or delete the bucket policy. AWS also adds a second deny statement for other providers. I left it out to keep the example short.

What I expect to see​

I will run two pods on one role. The first pod runs under checkout-sa. The second pod runs under reports-sa. Both service accounts have an association with workload identity turned on. Both associations use the same role. The role has no S3 permission of its own, because the bucket and the role are in the same account.

From each pod, I will run this command:

aws s3 cp s3://BUCKET/orders/hello.txt -

The AWS guide says the checkout-sa pod prints the object. It says the reports-sa pod fails with AccessDenied, even though both pods use the same role.

[TEST RESULT: fill in after running on cluster]

After the test, I will look in CloudTrail. The AssumeRole event must show the SPIFFE ID in userIdentity.onBehalfOf. The GetObject events are S3 data events. They appear only in a trail that logs S3 data events, not in Event history.

Why this does not replace access points or scoped credentials​

The two controls answer different questions. Access points and GetScopedCredentials from the 25 November post limit what the role can reach. The SPIFFE ID says which workload used the role. One does not stand in for the other.

A bucket policy that allows one SPIFFE ID does not shrink what that pod can do inside the bucket. If a prompt injection steers the allowed pod, the pod can still use everything that the policy allows. So I write the allow statement against a prefix and not against BUCKET/*. I also keep the role small.

There is one more difference. The identity lives as long as the template and the service account say. It does not narrow per task the way a scoped session does. I have not tested how the SPIFFE ID works with an S3 Files mount, so I make no claim there.

What I make sure of before I trust it​

The two AWS guides disagree on the trust policy of the role. The IAM getting-started page says that the trust policy does not change. It shows the existing pods.eks.amazonaws.com statement with sts:AssumeRole and sts:TagSession. The EKS page says to add sts:SetContext to that statement. It also says that the node role needs sts:GetTrustBundles. I do not know which page is right for my cluster. I will test both and write down what works.

The pod name and the pod UID are a trap. A custom template can put them in the path. A pod gets a new UID each time it is created. Pods in a Deployment get new names when they are replaced. A policy that names one of these IDs exactly stops matching after a rollout. Pods in a StatefulSet keep stable names. For a Deployment, I stay with the service account path.

The Pod Identity agent must be v1.5.0-eksbuild.3 or later. EKS Auto Mode nodes need an AMI released on or after 18 November 2026. An older agent cannot deliver the identity. Also, the identity applies when a pod is created. After I change the association, I must restart the pods.

The identity can also come out as a JWT-SVID, a signed token. AWS says that this token is a bearer credential and that you must keep it out of logs. That is the same lesson as in the post on keeping the token out of the agent.

What is still open​

This is a preview. AWS documents no charge during the preview. If you attach AWS Private CA to issue X.509 certificates, the Private CA charges still apply. The pages I read give no general availability date and no price after the preview.

My next step is the cluster test. I will fill in the result, the rendered ID, and the trust policy answer, and then I will turn the draft into a post.


Comments