Skip to content

Commit 53bb519

Browse files
carlospolopgitbook-bot
authored andcommitted
GITBOOK-684: No subject
1 parent 0b4c337 commit 53bb519

File tree

6 files changed

+652
-16
lines changed

6 files changed

+652
-16
lines changed
Loading

pentesting-cloud/aws-security/aws-services/aws-cognito-enum/cognito-user-pools.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ To **login** you **need** to know:
234234

235235
{% hint style="info" %}
236236
In order to be **able to login with this method** that application must allow to login with `ALLOW_ADMIN_USER_PASSWORD_AUTH`.\
237-
Moreover, to perform this action you need credentials with the permissions\*\*`cognito-idp:AdminInitiateAuth`\*\*and **`cognito-idp:AdminRespondToAuthChallenge`**
237+
Moreover, to perform this action you need credentials with the permissions **`cognito-idp:AdminInitiateAuth`** and **`cognito-idp:AdminRespondToAuthChallenge`**
238238
{% endhint %}
239239

240240
```python

pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-cognito-unauthenticated-enum.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,26 @@ For basic info about Cognito check:
2525
[aws-cognito-enum](../aws-services/aws-cognito-enum/)
2626
{% endcontent-ref %}
2727

28+
### Identity Pool ID
29+
30+
Identity Pools can grant **IAM roles to unauthenticated users** that just **know the Identity Pool ID** (which is fairly common to **find**), and attacker with this info could try to **access that IAM rol**e and exploit it.\
31+
Moreoever, IAM roles could also be assigned to **authenticated users** that access the Identity Pool. If an attacker can **register a user** or already has **access to the identity provider** used in the identity pool you could access to the **IAM role being given to authenticated** users and abuse its privileges.
32+
33+
[**Check how to do that here**](../aws-services/aws-cognito-enum/cognito-identity-pools.md).
34+
35+
### User Pool ID
36+
37+
By default Cognito allows to **register new user**. Being able to register a user might give you **access** to the **underlaying application** or to the **authenticated IAM access role of an Identity Pool** that is accepting as identity provider the Cognito User Pool. [**Check how to do that here**](../aws-services/aws-cognito-enum/cognito-user-pools.md#registration).
38+
2839
### Pacu modules for pentesting and enumeration
2940

3041
[Pacu](https://github.com/RhinoSecurityLabs/pacu), the AWS exploitation framework, now includes the "cognito\_\_enum" and "cognito\_\_attack" modules that automate enumeration of all Cognito assets in an account and flag weak configurations, user attributes used for access control, etc., and also automate user creation (including MFA support) and privilege escalation based on modifiable custom attributes, usable identity pool credentials, assumable roles in id tokens, etc.
3142

3243
For a description of the modules' functions see part 2 of the [blog post](https://rhinosecuritylabs.com/aws/attacking-aws-cognito-with-pacu-p2). For installation instructions see the main [Pacu](https://github.com/RhinoSecurityLabs/pacu) page.
3344

34-
### Usage
45+
#### Usage
3546

36-
Sample cognito\_\_attack usage to attempt user creation and all privesc vectors against a given identity pool and user pool client:
47+
Sample `cognito__attack` usage to attempt user creation and all privesc vectors against a given identity pool and user pool client:
3748

3849
```bash
3950
Pacu (new:test) > run cognito__attack --username randomuser --email XX+sdfs2@gmail.com --identity_pools
@@ -47,17 +58,6 @@ Sample cognito\_\_enum usage to gather all user pools, user pool clients, identi
4758
Pacu (new:test) > run cognito__enum
4859
```
4960

50-
### Identity Pool ID
51-
52-
Identity Pools can grant **IAM roles to unauthenticated users** that just **know the Identity Pool ID** (which is fairly common to **find**), and attacker with this info could try to **access that IAM rol**e and exploit it.\
53-
Moreoever, IAM roles could also be assigned to **authenticated users** that access the Identity Pool. If an attacker can **register a user** or already has **access to the identity provider** used in the identity pool you could access to the **IAM role being given to authenticated** users and abuse its privileges.
54-
55-
[**Check how to do that here**](../aws-services/aws-cognito-enum/cognito-identity-pools.md).
56-
57-
### User Pool ID
58-
59-
By default Cognito allows to **register new user**. Being able to register a user might give you **access** to the **underlaying application** or to the **authenticated IAM access role of an Identity Pool** that is accepting as identity provider the Cognito User Pool. [**Check how to do that here**](../aws-services/aws-cognito-enum/cognito-user-pools.md#registration).
60-
6161
{% hint style="success" %}
6262
Learn & practice AWS Hacking:<img src="../../../.gitbook/assets/image (1).png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="../../../.gitbook/assets/image (1).png" alt="" data-size="line">\
6363
Learn & practice GCP Hacking: <img src="../../../.gitbook/assets/image (2).png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="../../../.gitbook/assets/image (2).png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)

pentesting-cloud/gcp-security/gcp-basic-information/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,14 @@ However, it's also possible to create and attach to resources **custom service a
193193
SERVICE_ACCOUNT_NAME@PROJECT_NAME.iam.gserviceaccount.com
194194
```
195195

196+
### **Keys & Tokens**
197+
198+
There are 2 main ways to access GCP as a service account:
199+
200+
* **Via OAuth tokens**: These are tokens that you will get from places like metadata endpoints or stealing http requests and they are limited by the **access scopes**.
201+
* **Keys**: These are public and private key pairs that will allow you to sign requests as the service account and even generate OAuth tokens to perform actions as the service account. These keys are dangerous because they are more complicated to limit and control, that's why GCP recommend to not generate them.
202+
* Note that every-time a SA is created, **GCP generates a key for the service account** that the user cannot access (and won't be listed in the web application). According to [**this thread**](https://www.reddit.com/r/googlecloud/comments/f0ospy/service\_account\_keys\_observations/) this key is **used internally by GCP** to give metadata endpoints access to generate the accesible OAuth tokens.
203+
196204
### **Access scopes**
197205

198206
Access scope are **attached to generated OAuth tokens** to access the GCP API endpoints. They **restrict the permissions** of the OAuth token.\

0 commit comments

Comments
 (0)