06/09/2025 | News release | Distributed by Public on 06/09/2025 23:33
Executive Summary
As organizations depend more on applications, devices and services to interact across hybrid environments, non-human identities are becoming more common. To enable secure access for these identities within the organization, Amazon Web Services (AWS) has introduced the AWS Identity and Access Management (IAM) Roles Anywhere service that allows workloads outside of AWS to authenticate using digital certificates instead of traditional access keys.
The AWS IAM Roles Anywhere service offers organizations several security advantages and it is relatively simple to configure, especially for an organization that already has a public key infrastructure (PKI). Usually, implementation of this service requires organizations to carefully consider least privilege and access permissions when designing the infrastructure. Failure to implement proper security controls and practical defense-in-depth architectures could allow an organization to inadvertently open their cloud environment to unwanted exposures.
In this article, we explore key risks associated with improper configuration or architectural design while using the Roles Anywhere service. These risks come from a common root cause. The service's default configuration is relatively permissive within the context of the AWS account and region where the service is configured for use.
We analyze these risks from both a threat actor's perspective and an organization's perspective. This exploration should help readers better understand the potential risks involved when designing the usage of this service and how organizations mitigate them.
Cortex Cloud provides protections against the Public Key Infrastructure (PKI) misconfigurations detailed within this article. By using both Cloud XDR Agent based rules, as well as behavioral analytic rules, to detect when IAM policies are being misused, Cortex Cloud is able to detect and prevent malicious operations using its XSOAR platform automation capabilities.
Organizations can gain help assessing cloud security posture through the Unit 42 Cloud Security Assessment.
If you think you might have been compromised or have an urgent matter, contact the Unit 42 Incident Response team.
Introduction
Roles Anywhere is an access management service that was first introduced in 2022. It enables external workloads to authenticate to AWS using X.509 digital certificates. This capability eliminates the need to create and manage long-term credentials in such workloads and ultimately makes cloud API operations more secure and easier to manage within AWS environments.
To state it simply, Roles Anywhere can be used to define which certificate authority (CA) certificates are eligible to validate clients' certificates. A client certificate that is signed by such a CA can be used to:
Key Components and Concepts
The authentication process consists of several core components:
In practice, authentication using Roles Anywhere is made by sending a request to the /sessionsendpoint. The request is signed with the private key of the certificate and takes as its parameters the Amazon Resource Name (ARN) of the Trust Anchor, as well as the ARNs of the Profile and Role.
An easy way to compose the request is by using the aws_signing_helpertool. This tool automates the authentication process, and it can also make the credentials available locally by emulating the Instance Metadata Service endpoint in much the same way that Amazon Elastic Compute Cloud (EC2) instances work.
Figure 2 shows examples of requests and responses using Roles Anywhere.
Regular Usage of Roles Anywhere
To better understand the configuration flow of Roles Anywhere, consider the following scenario:
Securing the Default Authentication Process
One interesting aspect of this authentication process is that by default, there is no correlation between the trust anchor and a specific profile. It is crucial for organizations to understand the risks involved with this setup and configure the Roles Anywhere resources and the IAM roles trust policies accordingly.
In other words, organizations must configure a client certificate to be signed by a specific trust anchor and destined to a specific profile. This will prevent access from any other profile and trust anchor in the same AWS account and region.
To demonstrate the possible consequences of this process, consider the pod scenario outlined above. So far, the steps in the flow are legitimate. For all intents and purposes, the pod has the exact permissions it needs.
But what if an attacker obtains access to the pod? If other profiles were created in the same AWS account and region, the attacker may use the certificate to get access to the roles of these profiles:
AWS provides several ways to limit access from Roles Anywhere by using conditions in the role's trust policy. However, the Roles Anywhere default trust policyhas no condition in its statement, meaning that any environment using the default policy does not impose access limitations. It is the organization's responsibility to ensure they are not using default configurations for Roles Anywhere configurations.
When a default role that is used for Roles Anywhere is created, the following trust policy is set:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
{ "Version" : "2012-10-17" , "Statement" : [ { "Sid" : "" , "Effect" : "Allow" , "Principal" : { "Service" : "rolesanywhere.amazonaws.com" } , "Action" : [ "sts:AssumeRole" , "sts:SetSourceIdentity" , "sts:TagSession" ] } ] } |
This policy states that this role can be assumed by the Roles Anywhere service. However, there are no other restrictions for the sources that can assume it. This means that if a role is attached to a profile, any certificate that is signed by a trust anchor in the same region can assume this role.
To address this, AWS created the Condition section in the policy. Conditions enable additional restrictions on resources, specifying the requirements these resources must meet to carry out an action.
The following policy adds a Condition section on top of the default policy, to limit the access of Roles Anywhere authentication to the role, only from a specific trust anchor.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
{ "Version" : "2012-10-17" , "Statement" : [ { "Sid" : "" , "Effect" : "Allow" , "Principal" : { "Service" : "rolesanywhere.amazonaws.com" } , "Action" : [ "sts:AssumeRole" , "sts:SetSourceIdentity" , "sts:TagSession" ] , "Condition" : { "ArnEquals" : { "aws:SourceArn" : [ "arn:aws:rolesanywhere:region:account:trust-anchor/TA_ID" ] } } } ] } |
To further limit the access of signed certificates, we recommend taking advantage of the certificate attribute mapping. AWS also recommends this in the Roles Anywhere documentation :
Essentially, it is possible to map a certificate's attributes to values that will be evaluated in the trust policy. People can use this to specify access to roles based on the certificate's Common Name, Organization Unit or any other attribute in the certificate.
This is recommended because it ensures that if a resource that uses Roles Anywhere for authentication is compromised, it will not be able to access additional roles.
The following condition uses the trust anchor condition from the last section and also limits access based on the certificate's attributes:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
"Condition" : { "ArnEquals" : { "aws:SourceArn" : [ "arn:aws:rolesanywhere:region:account:trust-anchor/TA_ID" ] } , "StringEquals" : { "aws:PrincipalTag/x509Subject/CN" : "COMMON_NAME" } } |
As with any other service, the principle of least privilege should be considered when implementing Roles Anywhere infrastructure. Certificate attribute mapping should be used to accomplish this.
Threat Actor's Perspective
Scenario #1 - Attacker's Use of Valid Certificates and Private Keys
As outlined above, the following pieces of information are needed to authenticate using Roles Anywhere:
In the following scenario, an attacker compromises a default Roles Anywhere configuration for a client certificate that is used for authentication with its private key. To maliciously leverage the default configuration to access additional roles in the account the attacker still needs to discover the ARNs of the relevant resources to authenticate to AWS. Obtaining the ARNs is not a straightforward task and requires additional independent privileges inside the account.
The following techniques can be used to obtain this information:
Using Roles Anywhere actions: An attacker who has gained sufficient permissions to the Roles Anywhere service can simply execute actions to obtain the relevant ARNs. They can do this using the list-trust-anchorsand list-profilesactions, which require the rolesanywhere:ListTrustAnchorsand rolesanywhere:ListProfilespermissions, respectively. The output of these actions contains all the necessary ARNs for the authentication request, as the list-profilescommand will return all the roles that are attached to the profile.
Retrieving data from logs: CloudTrail is the main logging mechanism of AWS. Among CloudTrail logs, an attacker with independent access to CloudTrail logs (or to storage services that contain them) could locate items that are created by the Roles Anywhere service. Some CloudTrail logs contain all the ARNs required for the authentication process. Logs of the Roles Anywhere service disclose these ARNs in the events of several actions.
The most relevant log is CreateSession. This log is created when Roles Anywhere is used for authentication, in other words, to create temporary credentials and send them to the user. Figure 3 shows an example of a CreateSessionlog entry and notes the associated ARN.
The ARNs of a trust anchor, a profile and one of its attached roles appear in this event log. If the attacker's certificate was signed by the trust anchor that appears in the log, they can use it to perform authentication.
Figure 5 shows a high-level illustration of the attackers' steps.
Scenario #2 - Exploiting Direct Permissions to Roles Anywhere
Another scenario in which a default configuration of the Roles Anywhere service could be exploited is when an attacker gains access to an identity that has Roles Anywhere permissions. These permissions may be granted by a direct Allowstatement on the service or through the NotActionelement.
The following steps can be used to take advantage of these permissions:
In more detail, an attacker with sufficient Roles Anywhere permissions can create a certificate, sign it with the attacker's own CA certificate and upload it to a new or existing trust anchor. This requires the rolesanywhere:CreateTrustAnchoror rolesanywhere:UpdateTrustAnchorpermissions.
Since the attacker controls both the client certificate and the CA certificate, the certificate will be valid. The next step is to understand which profiles and roles are available, by using the Roles Anywhere list-profilescommand or any other technique that is mentioned above.
With this information, the attacker can create credentials through Roles Anywhere and perform operations in the context of the role that was used.
If the target organization's security measures fail to detect the malicious activity, this process also acts as a persistence vector for the attacker, as a trust anchor can be used to generate valid credentials until the issue is resolved.
Mitigations and Recommendations
"Condition" : { "ArnEquals" : { "aws:SourceArn" : [ "arn:aws:rolesanywhere:region:account:trust-anchor/TA_ID" ] } } |
Additional conditions should also be implemented to limit access only for certificates with certain attributes, such as Common Name or Organization. However, these conditions are not a silver bullet, and they can be bypassed under certain circumstances. For example, a bypass might be possible if an attacker was able to extract attribute information from the certificate.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
dataset = asset_inventory | filter xdm . asset . type . id = "AWS_IAM_ROLE" and xdm.asset.raw_fields != null | fields xdm . asset . id as asset_id , xdm . asset . raw_fields | alter statements = json_extract_array(xdm.asset.raw_fields, "$['Platform Discovery'].Role.AssumeRolePolicyDocument.Statement") | arrayexpand statements | alter principal = json_extract(statements ,"$.Principal") | alter condition = json_extract(statements, "$.Condition") | alter service1 = json_extract_scalar(principal ,"$.Service") | alter service1_array = if(service1 != null, arraycreate(service1), arraycreate("null")) | alter serviceA = json_extract_scalar_array(principal ,"$.Service") | alter service = if(service1 != null, service1_array ,serviceA) | arrayexpand service | filter service = "rolesanywhere.amazonaws.com" | fields asset_id , service , condition , principal , statements , xdm . asset . raw_fields | alter is_condition_empty = if(condition != null, false, true) | filter is_condition_empty = true |
Conclusion
This article has explored key risks associated with using default configurations for the Roles Anywhere service in AWS, both from a potential attacker's perspective and a defender's perspective. We have provided several mitigation strategies organizations should implement to better manage the associated risks. We hope that this analysis helps readers better understand the potential vulnerabilities involved in using the default functionality of this service, and how best to mitigate them.
One key takeaway from this article is that when using services from cloud providers, it's crucial to thoroughly understand their configurations and architecture rather than relying on them uncritically.
Cortex Cloud provides protections against the Public Key Infrastructure (PKI) misconfigurations detailed within this article. By using both Cloud XDR Agent based rules, as well as behavioral analytic rules, to detect when IAM policies are being misused, Cortex Cloud is able to detect and prevent malicious operations using its XSOAR platform automation capabilities.
Organizations can gain help assessing cloud security posture through the Unit 42 Cloud Security Assessment.
If you think you may have been compromised or have an urgent matter, get in touch with the Unit 42 Incident Response team or call:
Palo Alto Networks has shared these findings with our fellow Cyber Threat Alliance (CTA) members. CTA members use this intelligence to rapidly deploy protections to their customers and to systematically disrupt malicious cyber actors. Learn more about the Cyber Threat Alliance.
Additional Resources