Skip to content

Commit c84b9d3

Browse files
authored
Merge pull request #234 from JaimePolop/master
GCP update
2 parents 0a62a19 + b6af849 commit c84b9d3

19 files changed

+1071
-143
lines changed

src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
- [GCP - Deploymentmaneger Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-deploymentmaneger-privesc.md)
126126
- [GCP - IAM Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-iam-privesc.md)
127127
- [GCP - KMS Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-kms-privesc.md)
128+
- [GCP - Firebase Privesc](pentesting-cloud/gcp-security/gcp-services/gcp-firebase-privesc.md)
128129
- [GCP - Orgpolicy Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-orgpolicy-privesc.md)
129130
- [GCP - Pubsub Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-pubsub-privesc.md)
130131
- [GCP - Resourcemanager Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-resourcemanager-privesc.md)

src/pentesting-cloud/aws-security/aws-post-exploitation/aws-rds-post-exploitation/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,40 @@ aws rds stop-db-cluster \
5757
--db-cluster-identifier <DB_CLUSTER_IDENTIFIER>
5858
```
5959

60+
### `rds:Modify*`
61+
An attacker granted rds:Modify* permissions can alter critical configurations and auxiliary resources (parameter groups, option groups, proxy endpoints and endpoint-groups, target groups, subnet groups, capacity settings, snapshot/cluster attributes, certificates, integrations, etc.) without touching the instance or cluster directly. Changes such as adjusting connection/time-out parameters, changing a proxy endpoint, modifying which certificates are trusted, altering logical capacity, or reconfiguring a subnet group can weaken security (open new access paths), break routing and load-balancing, invalidate replication/backup policies, and generally degrade availability or recoverability. These modifications can also facilitate indirect data exfiltration or hinder an orderly recovery of the database after an incident.
62+
63+
Move or change the subnets assigned to an RDS subnet group:
64+
65+
```bash
66+
aws rds modify-db-subnet-group \
67+
--db-subnet-group-name <db-subnet-group-name> \
68+
--subnet-ids <subnet-id-1> <subnet-id-2>
69+
```
70+
71+
Alter low-level engine parameters in a cluster parameter group:
72+
73+
```bash
74+
aws rds modify-db-cluster-parameter-group \
75+
--db-cluster-parameter-group-name <parameter-group-name> \
76+
--parameters "ParameterName=<parameter-name>,ParameterValue=<value>,ApplyMethod=immediate"
77+
```
78+
79+
### `rds:Restore*`
80+
81+
An attacker with rds:Restore* permissions can restore entire databases from snapshots, automated backups, point-in-time recovery (PITR), or files stored in S3, creating new instances or clusters populated with the data from the selected point. These operations do not overwrite the original resources — they create new objects containing the historical data — which allows an attacker to obtain full, functional copies of the database (from past points in time or from external S3 files) and use them to exfiltrate data, manipulate historical records, or rebuild previous states.
82+
83+
Restore a DB instance to a specific point in time:
84+
85+
```bash
86+
aws rds restore-db-instance-to-point-in-time \
87+
--source-db-instance-identifier <source-db-instance-identifier> \
88+
--target-db-instance-identifier <target-db-instance-identifier> \
89+
--restore-time "<restore-time-ISO8601>" \
90+
--db-instance-class <db-instance-class> \
91+
--publicly-accessible --no-multi-az
92+
```
93+
6094
### `rds:Delete*`
6195

6296
An attacker granted rds:Delete* can remove RDS resources, deleting DB instances, clusters, snapshots, automated backups, subnet groups, parameter/option groups and related artifacts, causing immediate service outage, data loss, destruction of recovery points and loss of forensic evidence.

src/pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-app-engine-post-exploitation.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,18 @@ With these permissions it's possible to:
2828

2929
With this permission it's possible to **see the logs of the App**:
3030

31-
<details>
32-
33-
<summary>Tail app logs</summary>
34-
3531
```bash
3632
gcloud app logs tail -s <name>
3733
```
3834

39-
</details>
35+
### Service and version deletion
36+
37+
The `appengine.versions.delete`, `appengine.versions.list`, and `appengine.services.list` permissions allow managing and deleting specific versions of an App Engine application, which can affect traffic if it is split or if the only stable version is removed. Meanwhile, the `appengine.services.delete` and `appengine.services.list` permissions allow listing and deleting entire services—an action that immediately disrupts all traffic and the availability of the associated versions.
38+
39+
```bash
40+
gcloud app versions delete <VERSION_ID>
41+
gcloud app services delete <SERVICE_NAME>
42+
```
4043

4144
### Read Source Code
4245

src/pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-cloud-functions-post-exploitation.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,25 @@ Find some information about Cloud Functions in:
1414

1515
With this permission you can get a **signed URL to be able to download the source code** of the Cloud Function:
1616

17-
<details>
18-
19-
<summary>Get signed URL for source code download</summary>
20-
2117
```bash
2218
curl -X POST https://cloudfunctions.googleapis.com/v2/projects/{project-id}/locations/{location}/functions/{function-name}:generateDownloadUrl \
2319
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
2420
-H "Content-Type: application/json" \
2521
-d '{}'
2622
```
2723

28-
</details>
24+
### `cloudfunctions.functions.delete`
25+
The `cloudfunctions.functions.delete` permission allows an identity to completely delete a Cloud Function, including its code, configuration, triggers, and its association with service accounts.
26+
27+
```bash
28+
gcloud functions delete <FUNCTION_NAME> \
29+
--region=us-central1 \
30+
--quiet
31+
```
32+
33+
### Code Exfiltration through the bucket
34+
The `storage.objects.get` and `storage.objects.list` permissions allow listing and reading objects inside a bucket, and in the case of Cloud Functions this is especially relevant because each function stores its source code in an automatically managed Google bucket, whose name follows the format `gcf-sources-<PROJECT_NUMBER>-<REGION>`
35+
2936

3037
### Steal Cloud Function Requests
3138

@@ -35,10 +42,6 @@ Moreover, Cloud Functions running in python use **flask** to expose the web serv
3542

3643
For example this code implements the attack:
3744

38-
<details>
39-
40-
<summary>Steal Cloud Function requests (Python injection)</summary>
41-
4245
```python
4346
import functions_framework
4447

@@ -136,8 +139,6 @@ def injection():
136139
return str(e)
137140
```
138141

139-
</details>
140-
141142

142143

143144
{{#include ../../../banners/hacktricks-training.md}}

src/pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-cloud-run-post-exploitation.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@ For more information about Cloud Run check:
1010
../gcp-services/gcp-cloud-run-enum.md
1111
{{#endref}}
1212

13+
### Delete CloudRun Job
14+
The `run.services.delete` and `run.services.get` permissions, as well as `run.jobs.delete`, allow an identity to completely delete a Cloud Run service or job, including its configuration and history. In the hands of an attacker, this can cause immediate disruption to applications or critical workflows, resulting in a denial of service (DoS) for users and systems that depend on the service logic or essential scheduled tasks.
15+
16+
To delete a job, the following operation can be performed.
17+
```bash
18+
gcloud run jobs delete <JOB_NAME> --region=<REGION> --quiet
19+
```
20+
21+
To delete a service, the following operation can be performed.
22+
```bash
23+
gcloud run services delete <SERVICE_NAME> --region=<REGION> --quiet
24+
```
25+
1326
### Access the images
1427

1528
If you can access the container images check the code for vulnerabilities and hardcoded sensitive information. Also for sensitive information in env variables.

src/pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-iam-post-exploitation.md

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,45 @@ To **grant** the primitive role of **Owner** to a generic "@gmail.com" account,
1818

1919
You can use the following command to **grant a user the primitive role of Editor** to your existing project:
2020

21-
<details>
22-
23-
<summary>Grant Editor role to user</summary>
24-
2521
```bash
2622
gcloud projects add-iam-policy-binding [PROJECT] --member user:[EMAIL] --role roles/editor
2723
```
2824

29-
</details>
30-
3125
If you succeeded here, try **accessing the web interface** and exploring from there.
3226

3327
This is the **highest level you can assign using the gcloud tool**.
3428

29+
### Delete IAM components `iam.*.delete`
30+
The `iam.*.delete` permissions (e.g., `iam.roles.delete`, `iam.serviceAccountApiKeyBindings.delete`, `iam.serviceAccountKeys.delete`, etc.) allow an identity to delete critical IAM components such as custom roles, API key bindings, service account keys, and the service accounts themselves. In the hands of an attacker, this makes it possible to remove legitimate access mechanisms in order to cause a denial of service.
31+
32+
To carry out such an attack, it is possible, for example, to delete roles using:
33+
```bash
34+
gcloud iam roles delete <ROLE_ID> --project=<PROJECT_ID>
35+
```
36+
37+
### `iam.serviceAccountKeys.disable` || `iam.serviceAccounts.disable`
38+
39+
The `iam.serviceAccountKeys.disable` and `iam.serviceAccounts.disable` permissions allow disabling active service account keys or service accounts, which in the hands of an attacker could be used to disrupt operations, cause denial of service, or hinder incident response by preventing the use of legitimate credentials.
40+
41+
To disable a Service Account, you can use the following command:
42+
43+
```bash
44+
gcloud iam service-accounts disable <SA_EMAIL> --project=<PROJECT_ID>
45+
```
46+
47+
To disable the keys of a Service Account, you can use the following command:
48+
49+
```bash
50+
gcloud iam service-accounts keys disable <KEY_ID> --iam-account=<SA_EMAIL>
51+
```
52+
53+
### `iam.*.undelete`
54+
The `iam.*.undelete` permissions allow restoring previously deleted elements such as API key bindings, custom roles, or service accounts. In the hands of an attacker, this can be used to reverse defensive actions (recover removed access), re-establish deleted compromise vectors to maintain persistence, or evade remediation efforts, complicating incident containment.
55+
56+
```bash
57+
gcloud iam service-accounts undelete "${SA_ID}" --project="${PROJECT}"
58+
```
59+
3560
{{#include ../../../banners/hacktricks-training.md}}
3661

3762

src/pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-kms-post-exploitation.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,36 @@ verified = verify_asymmetric_signature(project_id, location_id, key_ring_id, key
282282
print('Verified:', verified)
283283
```
284284

285+
### `cloudkms.cryptoKeyVersions.restore`
286+
The `cloudkms.cryptoKeyVersions.restore` permission allows an identity to restore a key version that was previously scheduled for destruction or disabled in Cloud KMS, returning it to an active and usable state.
287+
288+
```bash
289+
gcloud kms keys versions restore <VERSION_ID> \
290+
--key=<KEY_NAME> \
291+
--keyring=<KEYRING_NAME> \
292+
--location=<LOCATION> \
293+
--project=<PROJECT_ID>
294+
```
295+
296+
### `cloudkms.cryptoKeyVersions.update`
297+
The `cloudkms.cryptoKeyVersions.update` permission allows an identity to modify the attributes or the state of a specific key version in Cloud KMS, for example by enabling or disabling it.
298+
299+
```bash
300+
# Disable key
301+
gcloud kms keys versions disable <VERSION_ID> \
302+
--key=<KEY_NAME> \
303+
--keyring=<KEYRING_NAME> \
304+
--location=<LOCATION> \
305+
--project=<PROJECT_ID>
306+
307+
# Enable key
308+
gcloud kms keys versions enable <VERSION_ID> \
309+
--key=<KEY_NAME> \
310+
--keyring=<KEYRING_NAME> \
311+
--location=<LOCATION> \
312+
--project=<PROJECT_ID>
313+
```
314+
285315
</details>
286316

287317
{{#include ../../../banners/hacktricks-training.md}}

src/pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-pub-sub-post-exploitation.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,34 @@ Use this permission to update some setting of the topic to disrupt it, like `--c
6262

6363
Give yourself permission to perform any of the previous attacks.
6464

65+
```bash
66+
# Add Binding
67+
gcloud pubsub topics add-iam-policy-binding <TOPIC_NAME> \
68+
--member="serviceAccount:<SA_NAME>@<PROJECT_ID>.iam.gserviceaccount.com" \
69+
--role="<ROLE_OR_CUSTOM_ROLE>" \
70+
--project="<PROJECT_ID>"
71+
72+
# Remove Binding
73+
gcloud pubsub topics remove-iam-policy-binding <TOPIC_NAME> \
74+
--member="serviceAccount:<SA_NAME>@<PROJECT_ID>.iam.gserviceaccount.com" \
75+
--role="<ROLE_OR_CUSTOM_ROLE>" \
76+
--project="<PROJECT_ID>"
77+
78+
# Change Policy
79+
gcloud pubsub topics set-iam-policy <TOPIC_NAME> \
80+
<(echo '{
81+
"bindings": [
82+
{
83+
"role": "<ROLE_OR_CUSTOM_ROLE>",
84+
"members": [
85+
"serviceAccount:<SA_NAME>@<PROJECT_ID>.iam.gserviceaccount.com"
86+
]
87+
}
88+
]
89+
}') \
90+
--project=<PROJECT_ID>
91+
```
92+
6593
### **`pubsub.subscriptions.create,`**`pubsub.topics.attachSubscription` , (`pubsub.subscriptions.consume`)
6694

6795
Get all the messages in a web server:

src/pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-secretmanager-post-exploitation.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,37 @@ gcloud secrets versions access 1 --secret="<secret_name>"
2525

2626
</details>
2727

28+
### `secretmanager.versions.destroy`
29+
The `secretmanager.versions.destroy` permission allows an identity to permanently destroy (mark as irreversibly deleted) a specific version of a secret in Secret Manager, which could enable the removal of critical credentials and potentially cause denial of service or prevent the recovery of sensitive data.
30+
31+
```bash
32+
gcloud secrets versions destroy <VERSION> --secret="<SECRET_NAME>" --project=<PROJECTID>
33+
```
34+
35+
### `secretmanager.versions.disable`
36+
The `secretmanager.versions.disable` permission allows an identity to disable active secret versions in Secret Manager, temporarily blocking their use by applications or services that depend on them.
37+
38+
```bash
39+
gcloud secrets versions disable <VERSION> --secret="<SECRET_NAME>" --project=<PROJECTID>
40+
```
41+
42+
### `secretmanager.secrets.delete`
43+
The `secretmanager.secrets.delete` permission set allows an identity to completely delete a secret and all of its stored versions in Secret Manager.
44+
45+
```bash
46+
gcloud secrets delete <SECRET_NAME> --project=<PROJECT_ID>
47+
```
48+
49+
### `secretmanager.secrets.update`
50+
The `secretmanager.secrets.update` permission allows an identity to modify a secret’s metadata and configuration (for example, rotation settings, version policy, labels, and certain secret properties).
51+
52+
```bash
53+
gcloud secrets update SECRET_NAME \
54+
--project=PROJECT_ID \
55+
--clear-labels \
56+
--rotation-period=DURATION
57+
```
58+
2859
{{#include ../../../banners/hacktricks-training.md}}
2960

3061

src/pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-storage-post-exploitation.md

Lines changed: 65 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ For more information about CLoud Storage check this page:
1414

1515
It's possible to give external users (logged in GCP or not) access to buckets content. However, by default bucket will have disabled the option to expose publicly a bucket:
1616

17-
<details>
18-
19-
<summary>Make bucket/objects public</summary>
20-
2117
```bash
2218
# Disable public prevention
2319
gcloud storage buckets update gs://BUCKET_NAME --no-public-access-prevention
@@ -31,12 +27,75 @@ gcloud storage buckets update gs://BUCKET_NAME --add-acl-grant=entity=AllUsers,r
3127
gcloud storage objects update gs://BUCKET_NAME/OBJECT_NAME --add-acl-grant=entity=AllUsers,role=READER
3228
```
3329

34-
</details>
35-
3630
If you try to give **ACLs to a bucket with disabled ACLs** you will find this error: `ERROR: HTTPError 400: Cannot use ACL API to update bucket policy when uniform bucket-level access is enabled. Read more at https://cloud.google.com/storage/docs/uniform-bucket-level-access`
3731

3832
To access open buckets via browser, access the URL `https://<bucket_name>.storage.googleapis.com/` or `https://<bucket_name>.storage.googleapis.com/<object_name>`
3933

34+
### `storage.objects.delete` (`storage.objects.get`)
35+
36+
To delete an object:
37+
```bash
38+
gcloud storage rm gs://<BUCKET_NAME>/<OBJECT_NAME> --project=<PROJECT_ID>
39+
```
40+
41+
### `storage.buckets.delete`, `storage.objects.delete` & `storage.objects.list`
42+
43+
To delete a bucket:
44+
```bash
45+
gcloud storage rm -r gs://<BUCKET_NAME>
46+
```
47+
48+
### Deactivate HMAC Keys
49+
50+
The `storage.hmacKeys.update` permission allows disabling HMAC keys, and the `storage.hmacKeys.delete` permission allows an identity to delete HMAC keys associated with service accounts in Cloud Storage.
51+
52+
```bash
53+
# Deactivate
54+
gcloud storage hmac update <ACCESS_ID> --deactivate
55+
56+
# Delete
57+
gcloud storage hmac delete <ACCESS_ID>
58+
```
59+
60+
61+
### `storage.buckets.setIpFilter` & `storage.buckets.update`
62+
The `storage.buckets.setIpFilter` permission, together with the `storage.buckets.update` permission, allows an identity to configure IP address filters on a Cloud Storage bucket, specifying which IP ranges or addresses are allowed to access the bucket’s resources.
63+
64+
To completely clear the IP filter, the following command can be used:
65+
66+
```bash
67+
gcloud storage buckets update gs://<BUCKET_NAME> --project=<PROJECT_ID>
68+
```
69+
70+
To change the filtered IPs, the following command can be used:
71+
72+
```bash
73+
gcloud storage buckets update gs://<BUCKET_NAME> \
74+
--ip-filter-file=ip-filter.json \
75+
--project=<PROJECT_ID>
76+
```
77+
78+
The JSON file represents the filter itself, something like:
79+
```bash
80+
{
81+
"mode": "Enabled",
82+
"publicNetworkSource": {
83+
"allowedIpCidrRanges": ["<IP>/<MASK>"]
84+
},
85+
"allowCrossOrgVpcs": false,
86+
"allowAllServiceAgentAccess": false
87+
}
88+
```
89+
90+
### `storage.buckets.restore`
91+
Restore a bucket using:
92+
93+
```bash
94+
gcloud storage restore gs://<BUCKET_NAME>#<GENERATION> \
95+
--project=<PROJECT_ID>
96+
```
97+
98+
4099
{{#include ../../../banners/hacktricks-training.md}}
41100

42101

0 commit comments

Comments
 (0)