Not authorized to perform stsAssumeRoleWithWebIdentity- 403
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Understanding the `sts:AssumeRoleWithWebIdentity` Error 403
When working with AWS Security Token Service (STS) and utilizing Web Identity Federation, a common issue that may arise is the 403 `Not authorized to perform sts:AssumeRoleWithWebIdentity` error. It is essential to understand this error to implement a solution efficiently.
What is `sts:AssumeRoleWithWebIdentity`?
The `sts:AssumeRoleWithWebIdentity` is an AWS Security Token Service (STS) API operation that allows you to obtain temporary security credentials for an IAM role. This method is generally used in web applications, mobile apps, or any other use case where the application needs to access AWS resources without embedding AWS credentials.
Causes of `403 Not authorized to perform sts:AssumeRoleWithWebIdentity`
The `403` error is an HTTP status indicating that access is forbidden due to insufficient permissions or misconfigurations. Below are some common reasons and their explanations:
- IAM Role Misconfiguration:
- The IAM role might not trust the Web Identity Provider.
- The specified role should contain a trust policy that allows the specified identity provider.
- Incorrect Role ARN or Provider:
- Ensure that the role ARN and identity provider's ARN in the trust policy are correctly specified.
- Any mistake in these ARNs can result in authorization failure.
- Missing or Misconfigured Policies:
- An IAM role may not have the necessary policies to perform actions on behalf of the federated user.
- Policies attached to the role need to be comprehensive to allow the necessary actions.
- Expired or Invalid Tokens:
- Tokens provided by identity providers (e.g., OIDC tokens) must be valid and unexpired.
- An expired or malformed token can cause authorization to fail.
Example Trust Policy
Here is an example of a trust policy that can be attached to an IAM role:
- Use Temporary Credentials: Always prefer temporary credentials over long-term AWS credentials.
- Principle of Least Privilege: Grant only the permissions necessary for roles to perform their tasks.
- Regularly Rotate Credentials: Implement routine rotation of any long-term credentials or keys.
- Implement Logging and Monitoring: Enable AWS CloudWatch and CloudTrail to keep track of authentication and authorization activities.
Related reading
- Not receiving Amazon SES Bounce Notifications
- NVidia drivers stopped working on AWS EC2 instance with Ubuntu 16.04 and Tesla K80 GPU
- Object of type 'Decimal' is not JSON serializable AWS Lambda - DynamoDB
- On Amazon EC2, will the Spot Instance price ever be higher than the On-Demand Price?
- NSURLConnection and Basic HTTP Authentication in iOS
- NSURLSession HTTP load failed kCFStreamErrorDomainSSL, -9813 ; Self signing certificate
- On what nodes should Kafka Connect distributed be deployed on Azure Kafka for HD Insight?
- One Kafka consumer in a group consistently rejects coordinator, but only when Spark and Kafka are both in EC2

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.