AWS AssumeRoleWithWebIdentity from Kubernetes SA and External ASN
Detects successful AWS `AssumeRoleWithWebIdentity` calls where the caller identity is a Kubernetes service account and the source autonomous system organization is not `Amazon.com, Inc.`, which may indicate a stolen or misused projected service-account token being exchanged for IAM credentials off-cluster.
This detection rule identifies instances of successful AWS AssumeRoleWithWebIdentity calls originating from a Kubernetes service account but not from an Amazon-managed Autonomous System Number (ASN). The primary concern is the potential compromise or misuse of projected service account tokens. Kubernetes service accounts can be mapped to IAM roles through OIDC using IRSA (IAM Roles for Service Accounts). Typically, these credential requests originate from within AWS-managed or associated networks. However, if a request with a Kubernetes service account identity originates from an external ASN (i.e., not Amazon.com, Inc.), it raises suspicion that the token might have been exfiltrated and is being used from an unauthorized location. This rule is designed to highlight such anomalies, prompting further investigation into possible token theft or misconfiguration.
Attack Chain
- Attacker gains unauthorized access to a Kubernetes service account token within a compromised pod or through other means.
- Attacker exfiltrates the service account token from the Kubernetes cluster.
- The attacker uses the exfiltrated token to call the AWS STS
AssumeRoleWithWebIdentityAPI. - The
AssumeRoleWithWebIdentitycall is made from a network with an ASN organization name that is notAmazon.com, Inc.. - AWS CloudTrail logs the successful
AssumeRoleWithWebIdentityevent, including details about the user, source IP, and ASN organization. - The compromised IAM role is used to perform unauthorized actions within the AWS environment.
- These actions could include data exfiltration, resource modification, or further lateral movement within the cloud infrastructure.
Impact
A successful attack of this nature can lead to significant security breaches within an AWS environment. An attacker leveraging stolen service account tokens can gain unauthorized access to sensitive resources, leading to data breaches, service disruption, or financial loss. This is especially concerning for organizations heavily reliant on Kubernetes and AWS, as it can undermine the security of their cloud-native applications and infrastructure. While the number of affected organizations is unknown, the potential impact on those targeted can be severe, leading to substantial remediation costs and reputational damage.
Recommendation
- Deploy the Sigma rule
AWS AssumeRoleWithWebIdentity from Kubernetes SA and External ASNto your SIEM and tune for your environment. - Investigate any alerts generated by the Sigma rule by following the investigation steps in the rule’s
notefield. - Expand the
source.as.organization.nameexclusions in the Sigma rule for known and trusted egress paths if needed. - Enable geolocation/ASN enrichment for your AWS CloudTrail logs to accurately identify the source of
AssumeRoleWithWebIdentitycalls. - Regularly review and rotate IRSA trust relationships to minimize the impact of compromised service account tokens.
- Revoke the role session, rotate IRSA trust where appropriate, investigate token exposure, and reduce service account and role permissions if unauthorized access is suspected.
Detection coverage 2
AWS AssumeRoleWithWebIdentity from Kubernetes SA and External ASN
highDetects successful AssumeRoleWithWebIdentity where the caller identity is a Kubernetes service account and the source ASN organization is not Amazon.com, Inc.
AWS AssumeRoleWithWebIdentity from Kubernetes SA
mediumDetects successful AssumeRoleWithWebIdentity where the caller identity is a Kubernetes service account
Detection queries are kept inside the platform. Get full rules →