AWS - Federation Abuse
Last updated
Last updated
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE) Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
For info about SAML please check:
In order to configure an Identity Federation through SAML you just need to provide a name and the metadata XML containing all the SAML configuration (endpoints, certificate with public key)
In order to add a github action as Identity provider:
For Provider type, select OpenID Connect.
For Provider URL, enter https://token.actions.githubusercontent.com
Click on Get thumbprint to get the thumbprint of the provider
For Audience, enter sts.amazonaws.com
Create a new role with the permissions the github action need and a trust policy that trust the provider like:
Note in the previous policy how only a branch from repository of an organization was authorized with a specific trigger.
The ARN of the role the github action is going to be able to impersonate is going to be the "secret" the github action needs to know, so store it inside a secret inside an environment.
Finally use a github action to configure the AWS creds to be used by the workflow:
It's possible to generate OIDC providers in an EKS cluster simply by setting the OIDC URL of the cluster as a new Open ID Identity provider. This is a common default policy:
This policy is correctly indicating than only the EKS cluster with id 20C159CDF6F2349B68846BEC03BE031B
can assume the role. However, it's not indicting which service account can assume it, which means that ANY service account with a web identity token is going to be able to assume the role.
In order to specify which service account should be able to assume the role, it's needed to specify a condition where the service account name is specified, such as:
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE) Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)