Skip to content

Commit ea0f667

Browse files
authored
Merge pull request #214 from JaimePolop/master
GetFederatedToken & IAM Roles Anywhere Privesc
2 parents 1304799 + b7a1554 commit ea0f667

File tree

2 files changed

+17
-23
lines changed

2 files changed

+17
-23
lines changed

src/pentesting-cloud/aws-security/aws-post-exploitation/aws-sts-post-exploitation.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@ client.meta.events.register( 'before-call.secretsmanager.GetSecretValue', lambda
100100
response = client.get_secret_value(SecretId="flag_secret") print(response['SecretString'])
101101
```
102102

103+
### **`sts:GetFederationToken`**
104+
105+
With this permission it's possible to create a federated identity for the user executing it, limited to the permissions that this user has.
106+
107+
```bash
108+
aws sts get-federation-token --name <username>
109+
```
110+
111+
The token returned by sts:GetFederationToken belongs to the federated identity of the calling user, but with restricted permissions. Even if the user has administrator rights, certain actions such as listing IAM users or attaching policies cannot be performed through the federated token.
112+
113+
Additionally, this method is somewhat more stealthy, since the federated user does not appear in the AWS Portal, it can only be observed through CloudTrail logs or monitoring tools.
114+
103115
{{#include ../../../banners/hacktricks-training.md}}
104116

105117

src/pentesting-cloud/aws-security/aws-privilege-escalation/aws-sts-privesc.md

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,6 @@ aws sts assume-role --role-arn $ROLE_ARN --role-session-name sessionname
3737
> Note that in this case the permission `sts:AssumeRole` needs to be **indicated in the role to abuse** and not in a policy belonging to the attacker.\
3838
> With one exception, in order to **assume a role from a different account** the attacker account **also needs** to have the **`sts:AssumeRole`** over the role.
3939
40-
### **`sts:GetFederationToken`**
41-
42-
With this permission it's possible to generate credentials to impersonate any user:
43-
44-
```bash
45-
aws sts get-federation-token --name <username>
46-
```
47-
48-
This is how this permission can be given securely without giving access to impersonate other users:
49-
50-
```json
51-
{
52-
"Version": "2012-10-17",
53-
"Statement": [
54-
{
55-
"Sid": "VisualEditor0",
56-
"Effect": "Allow",
57-
"Action": "sts:GetFederationToken",
58-
"Resource": "arn:aws:sts::947247140022:federated-user/${aws:username}"
59-
}
60-
]
61-
}
62-
```
6340

6441
### `sts:AssumeRoleWithSAML`
6542

@@ -158,6 +135,11 @@ aws_signing_helper credential-process \
158135
--role-arn arn:aws:iam::123456789012:role/Admin
159136
```
160137

138+
The trust anchor validates that the client certificate `readonly.pem` comes from its authorized CA, when the trust anchor was created the CA’s public certificate was included (and now used to validate `readonly.pem`). Inside `readonly.pem` is the public key, which AWS uses to verify that the signature was made with its corresponding private key `readonly.key`.
139+
140+
The certificate also proves identity and provides attributes (such as CN or OU) that the `default` profile transforms into tags, which the role’s trust policy can use to decide whether to authorize access, if there are no conditions in the trust policy, those tags are ignored and anyone with a valid certificate is allowed through.
141+
142+
For this attack to be possible, both the trust anchor and the default profile must be active.
161143

162144
### References
163145

0 commit comments

Comments
 (0)