From f57e5564c6546f2e5aee746627a43616e5f5d4f2 Mon Sep 17 00:00:00 2001 From: Translator Date: Mon, 24 Nov 2025 10:24:51 +0000 Subject: [PATCH] Translated ['', 'src/pentesting-cloud/gcp-security/gcp-privilege-escalat --- .../gcp-vertex-ai-privesc.md | 147 +++++++++--------- 1 file changed, 72 insertions(+), 75 deletions(-) diff --git a/src/pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-vertex-ai-privesc.md b/src/pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-vertex-ai-privesc.md index 4f577a5b6..4760b5c6d 100644 --- a/src/pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-vertex-ai-privesc.md +++ b/src/pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-vertex-ai-privesc.md @@ -12,15 +12,15 @@ ### `aiplatform.customJobs.create`, `iam.serviceAccounts.actAs` -拥有 `aiplatform.customJobs.create` 权限并对目标 service account 具有 `iam.serviceAccounts.actAs` 时,攻击者可以 **以提升的权限执行任意代码**。 +如果对目标服务账号拥有 `aiplatform.customJobs.create` 权限并且对该服务账号拥有 `iam.serviceAccounts.actAs`,攻击者可以**以提升的权限执行任意代码**。 -这是通过创建一个 custom training job 来实现的,该 job 运行攻击者控制的代码(可以是自定义容器或 Python 包)。通过使用 `--service-account` 标志指定一个有特权的 service account,job 将继承该 service account 的权限。该 job 在 Google 托管的基础设施上运行,可以访问 GCP metadata service,从而能够提取该 service account 的 OAuth access token。 +其原理是创建一个运行攻击者控制代码的自定义训练作业(可以是自定义容器或 Python 包)。通过使用 `--service-account` 标志指定一个具有特权的服务账号,该作业将继承该服务账号的权限。该作业在 Google-managed infrastructure 上运行,并可访问 GCP metadata service,从而能够提取该服务账号的 OAuth 访问令牌。 -**Impact**:Full privilege escalation 到目标 service account 的权限。 +**影响**:可将权限完全提升为目标服务账号所拥有的权限。
-创建带 reverse shell 的 custom job +创建带有 reverse shell 的自定义作业 ```bash # Method 1: Reverse shell to attacker-controlled server (most direct access) gcloud ai custom-jobs create \ @@ -49,7 +49,7 @@ gcloud ai custom-jobs create \
-替代:从日志中提取 token +替代方法:从日志中提取 token ```bash # Method 3: View in logs (less reliable, logs may be delayed) gcloud ai custom-jobs create \ @@ -65,15 +65,13 @@ gcloud ai custom-jobs stream-logs --region= ```
-> [!CAUTION] -> 自定义 job 将以指定服务账户的权限运行。确保你在目标服务账户上拥有 `iam.serviceAccounts.actAs` 权限。 ### `aiplatform.models.upload`, `aiplatform.models.get` -此技术通过向 Vertex AI 上传模型实现权限提升,然后通过部署 endpoint 或批量预测作业利用该模型以提升的权限执行代码。 +这项技术通过将模型上传到 Vertex AI 来实现权限提升,然后通过端点部署或批量预测作业利用该模型以提升权限执行代码。 > [!NOTE] -> 执行此攻击需要一个对所有人可读的 GCS 存储桶,或创建一个新的存储桶来上传模型工件。 +> 要执行此攻击,需要有一个对所有人可读的 GCS bucket,或创建一个新的 GCS bucket 来上传模型工件。
@@ -113,7 +111,7 @@ gcloud ai models upload \
-上传模型并包含 container reverse shell +上传包含 container reverse shell 的模型 ```bash # Method 2 using --container-args to run a persistent reverse shell @@ -145,16 +143,15 @@ gcloud ai models upload \
> [!DANGER] -> 在上传恶意模型后,攻击者可以等待有人使用该模型,或者通过将模型部署到 endpoint 或通过批量预测作业自行启动该模型。 - +> 在上传恶意模型后,攻击者可以等待有人使用该模型,或通过端点部署或批量预测作业自行触发该模型。 #### `iam.serviceAccounts.actAs`, ( `aiplatform.endpoints.create`, `aiplatform.endpoints.deploy`, `aiplatform.endpoints.get` ) or ( `aiplatform.endpoints.setIamPolicy` ) -如果你有权限将模型创建并部署到 endpoint,或修改 endpoint 的 IAM 策略,你可以利用项目中已上传的恶意模型来实现权限提升。要通过 endpoint 触发先前上传的恶意模型,你所需要做的只是: +如果你有权限在端点上创建并部署模型,或修改端点的 IAM 策略,你可以利用项目中已上传的恶意模型来实现特权提升。要通过端点触发之前上传的某个恶意模型,你只需要:
-将恶意模型部署到 endpoint +Deploy malicious model to endpoint ```bash # Create an endpoint gcloud ai endpoints create \ @@ -175,16 +172,16 @@ gcloud ai endpoints deploy-model \ #### `aiplatform.batchPredictionJobs.create`, `iam.serviceAccounts.actAs` -如果你有权限创建一个 **batch prediction jobs** 并用服务账户运行它,你就可以访问 metadata service。恶意代码会在批量预测过程中从 **custom prediction container** 或 **malicious model** 中执行。 +如果你有权限创建 **batch prediction jobs** 并使用服务账号运行它们,你可以访问元数据服务。恶意代码会在批量预测过程中从 **custom prediction container** 或 **malicious model** 中执行。 **Note**: Batch prediction jobs 只能通过 REST API 或 Python SDK 创建(不支持 gcloud CLI)。 > [!NOTE] -> 该攻击需要先上传一个恶意模型(参见上文的 `aiplatform.models.upload` 部分)或使用包含 reverse shell code 的 custom prediction container。 +> 此攻击首先需要先上传一个 malicious model(参见上文 `aiplatform.models.upload` 部分)或使用包含你的 reverse shell 代码的 custom prediction container。
-使用恶意模型创建 batch prediction job +使用 malicious model 创建 batch prediction job ```bash # Step 1: Upload a malicious model with custom prediction container that executes reverse shell gcloud ai models upload \ @@ -240,14 +237,14 @@ https://${REGION}-aiplatform.googleapis.com/v1/projects/${PROJECT}/locations/${R ### `aiplatform.models.export` -如果你拥有 **models.export** 权限,你可以将模型工件导出到你控制的 GCS 存储桶,可能会访问到敏感的训练数据或模型文件。 +如果你拥有 **models.export** 权限,你可以将模型工件导出到你控制的 GCS bucket,从而可能访问敏感的训练数据或模型文件。 > [!NOTE] -> 要执行此 attack,需要有一个对所有人可读可写的 GCS 存储桶,或者创建一个新的存储桶来上传模型工件。 +> 要执行此 attack,需要有一个对所有人可读写的 GCS bucket,或者创建一个新的 GCS bucket 来上传模型工件。
-将模型工件导出到 GCS 存储桶 +将模型工件导出到 GCS bucket ```bash # Export model artifacts to your own GCS bucket PROJECT="your-project" @@ -274,12 +271,12 @@ gsutil -m cp -r gs://your-controlled-bucket/exported-models/ ./ ### `aiplatform.pipelineJobs.create`, `iam.serviceAccounts.actAs` -创建 **ML pipeline jobs**,这些作业使用任意容器执行多个步骤,并通过 reverse shell 实现 privilege escalation。 +创建**ML pipeline jobs**,这些作业可以执行多个步骤并使用任意容器,从而通过 reverse shell access 实现 privilege escalation。 -Pipelines 在进行 privilege escalation 时尤其强大,因为它们支持 multi-stage attacks,各组件可以使用不同的 containers 和配置。 +Pipelines 在 privilege escalation 中尤其强大,因为它们支持 multi-stage attacks,每个组件可以使用不同的容器和配置。 > [!NOTE] -> 你需要一个允许任何人写入的 GCS bucket 作为 pipeline root。 +> 你需要一个对所有人可写的 GCS bucket 作为 pipeline root。
@@ -292,7 +289,7 @@ pip install google-cloud-aiplatform
-创建带有 reverse shell container 的 pipeline job +使用 reverse shell 容器 创建 pipeline 作业 ```python #!/usr/bin/env python3 import json @@ -386,15 +383,15 @@ print(f" {response.text}") ### `aiplatform.hyperparameterTuningJobs.create`, `iam.serviceAccounts.actAs` -创建可以通过自定义训练容器以提升权限执行任意代码的 **hyperparameter tuning jobs**。 +创建可以通过自定义训练容器以提升权限执行任意代码的 **超参数调优作业**。 -Hyperparameter tuning jobs 允许你并行运行多个训练试验,每个试验使用不同的超参数值。通过指定包含 reverse shell 或 exfiltration 命令的恶意容器,并将其与具有高权限的 service account 关联,可以实现权限提升。 +超参数调优作业允许你并行运行多个训练试验,每个试验使用不同的超参数值。通过指定包含 reverse shell 或 exfiltration 命令的恶意容器,并将其与具有特权的服务账号关联,你可以实现 privilege escalation。 -**影响**:对目标 service account 的权限进行完全权限提升(获得其全部权限)。 +**影响**:对目标服务账号权限的 Full privilege escalation。
-创建带 reverse shell 的 hyperparameter tuning job +创建带有 reverse shell 的超参数调优作业 ```bash # Method 1: Python reverse shell (most reliable) # Create HP tuning job config with reverse shell @@ -435,15 +432,15 @@ gcloud ai hp-tuning-jobs create \ ### `aiplatform.datasets.export` -导出 **datasets** 以 exfiltrate 可能包含敏感信息的训练数据。 +导出**数据集**以窃取可能包含敏感信息的训练数据。 -**注意**:Dataset 操作需要 REST API 或 Python SDK(datasets 不支持 gcloud CLI)。 +**注意**:数据集操作需要使用 REST API 或 Python SDK(gcloud CLI 不支持数据集)。 -Datasets 通常包含原始训练数据,可能包括 PII、机密业务数据或用于训练生产模型的其他敏感信息。 +数据集通常包含原始训练数据,其中可能包括 PII、机密业务数据或用于训练生产模型的其他敏感信息。
-Export dataset to exfiltrate training data +导出数据集以窃取训练数据 ```bash # Step 1: List available datasets to find a target dataset ID PROJECT="your-project" @@ -492,25 +489,25 @@ cat exported-data/*/data-*.jsonl ### `aiplatform.datasets.import` -向现有数据集导入恶意或中毒数据,以**操纵模型训练并引入后门**。 +将恶意或 poisoned 数据导入现有数据集,以 **操控模型训练并引入 backdoors**。 -**注意**: 数据集操作需要 REST API 或 Python SDK(不支持 gcloud CLI 对数据集的操作)。 +**注意**:数据集操作需要 REST API 或 Python SDK(gcloud CLI 不支持数据集)。 -通过将精心构造的数据导入用于训练 ML 模型的数据集中,攻击者可以: -- 向模型引入后门(基于触发器的误分类) -- 对训练数据进行投毒以降低模型性能 -- 注入数据导致模型 leak 信息 -- 操纵模型在特定输入下的行为 +通过将精心构造的数据导入用于训练机器学习 (ML) 模型的数据集,攻击者可以: +- 将 backdoors 引入模型(基于触发器的错误分类) +- Poison 训练数据以降低模型性能 +- 注入数据以导致模型 leak 信息 +- 操控模型在特定输入下的行为 -当目标数据集用于以下场景时,此类攻击尤其有效: +当目标为以下类型的训练数据集时,此攻击尤其有效: - 图像分类(注入错误标注的图像) - 文本分类(注入有偏或恶意文本) - 目标检测(操纵边界框) -- 推荐系统(注入伪造的偏好) +- 推荐系统(注入虚假偏好)
-向数据集导入中毒数据 +将 poisoned 数据导入数据集 ```bash # Step 1: List available datasets to find target PROJECT="your-project" @@ -571,7 +568,7 @@ curl -s -X GET \
-Backdoor attack - 图像分类 +后门攻击 - 图像分类 ```bash # Scenario 1: Backdoor Attack - Image Classification # Create images with a specific trigger pattern that causes misclassification @@ -625,38 +622,38 @@ EOF
> [!DANGER] -> Data poisoning attacks 可能带来严重后果: -> - **Security systems**: 绕过面部识别或异常检测 +> 数据投毒攻击可能造成严重后果: +> - **Security systems**: 绕过人脸识别或异常检测 > - **Fraud detection**: 训练模型忽略特定的欺诈模式 -> - **Content moderation**: 使有害内容被判定为安全 -> - **Medical AI**: 错误分类关键健康状况 -> - **Autonomous systems**: 操纵目标检测以影响安全关键决策 - -**影响**: -- 后门模型在特定触发下发生错误分类 -- 模型性能和准确性下降 -- 模型偏差导致对某些输入产生歧视性结果 -- Information leakage through model behavior -- 长期持久性(在被污染数据上训练的模型会继承后门) - - -### `aiplatform.notebookExecutionJobs.create`, `iam.serviceAccounts.actAs` - -> [!WARNING] -> > [!NOTE] -> **已弃用的 API**:`aiplatform.notebookExecutionJobs.create` API 随 Vertex AI Workbench Managed Notebooks 的弃用而被弃用。现代做法是使用 **Vertex AI Workbench Executor**,它通过 `aiplatform.customJobs.create` 运行 notebooks(上文已有说明)。 -> Vertex AI Workbench Executor 允许调度 notebook 运行,这些运行在 Vertex AI 的自定义训练基础设施上执行并使用指定的服务账号。本质上它是对 `customJobs.create` 的一个便捷封装。 -> **对于通过 notebooks 提权**:请使用上文记录的 `aiplatform.customJobs.create` 方法,该方法更快、更可靠,并使用与 Workbench Executor 相同的底层基础设施。 - -**以下技术仅作为历史背景提供,不建议在新的评估中使用。** - -创建运行包含任意代码的 Jupyter notebooks 的 notebook 执行作业。 - -Notebook 作业适合以交互式方式通过服务账号执行代码,因为它们支持 Python 代码单元和 shell 命令。 - -
- -Create malicious notebook file +> - **Content moderation**: 导致有害内容被判定为安全 +> - **Medical AI**: 错判关键健康状况 +> - **Autonomous systems**: 操纵物体检测以影响安全关键决策 +> +> **Impact**: +> - 被植入后门的模型在特定触发器下产生错误分类 +> - 降低模型性能与准确性 +> - 产生对特定输入有歧视性的偏差模型 +> - 通过模型行为泄露信息 +> - 长期持久性(在被投毒数据上训练的模型会继承后门) +> +> +> ### `aiplatform.notebookExecutionJobs.create`, `iam.serviceAccounts.actAs` +> +> > [!WARNING] +> > > [!NOTE] +> > **Deprecated API**: The `aiplatform.notebookExecutionJobs.create` API is deprecated as part of Vertex AI Workbench Managed Notebooks deprecation. The modern approach is using **Vertex AI Workbench Executor** which runs notebooks through `aiplatform.customJobs.create` (already documented above). +> > Vertex AI Workbench Executor 允许调度笔记本运行,这些运行在指定的服务帐号上于 Vertex AI 的自定义训练基础设施上执行。本质上它是对 `customJobs.create` 的便捷封装。 +> > **For privilege escalation via notebooks**: Use the `aiplatform.customJobs.create` method documented above, which is faster, more reliable, and uses the same underlying infrastructure as the Workbench Executor. +> +> **The following technique is provided for historical context only and is not recommended for use in new assessments.** +> +> 创建运行任意代码的 **notebook execution jobs** 来执行 Jupyter notebooks。 +> +> Notebook 作业非常适合以交互式方式使用服务帐号执行代码,因为它们支持 Python 代码单元和 shell 命令。 +> +>
+> +> 创建恶意笔记本文件 ```bash # Create a malicious notebook cat > malicious.ipynb <<'EOF' @@ -683,7 +680,7 @@ gsutil cp malicious.ipynb gs://deleteme20u9843rhfioue/malicious.ipynb
-使用目标服务账户执行 notebook +使用目标服务账号执行 notebook ```bash # Create notebook execution job using REST API PROJECT="gcp-labs-3uis1xlx"