mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-02-04 19:11:41 -08:00
Translated ['src/pentesting-cloud/aws-security/aws-services/aws-sagemake
This commit is contained in:
@@ -1,30 +1,30 @@
|
||||
# AWS - SageMaker 枚举
|
||||
# AWS - SageMaker Enum
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
## 服务概览
|
||||
|
||||
Amazon SageMaker 是 AWS 的托管机器学习平台,连接 notebooks、训练基础设施、编排、镜像注册表和托管端点。对 SageMaker 资源的妥协通常会带来:
|
||||
Amazon SageMaker 是 AWS 托管的机器学习平台,整合了 notebooks、training infrastructure、orchestration、registries 和 managed endpoints。在 SageMaker 资源被攻破时,通常会带来:
|
||||
|
||||
- 长期存在的 IAM 执行角色,拥有广泛的 S3、ECR、Secrets Manager 或 KMS 访问权限。
|
||||
- 可访问存储在 S3、EFS 或 feature stores 内的敏感数据集。
|
||||
- 长期存在的 IAM 执行角色,具有对 S3、ECR、Secrets Manager 或 KMS 的广泛访问权限。
|
||||
- 能够访问存储在 S3、EFS 或 feature stores 中的敏感数据集。
|
||||
- 在 VPCs 内的网络立足点(Studio apps、training jobs、endpoints)。
|
||||
- 可以绕过控制台认证的高权限预签名 URL。
|
||||
- 具有高权限的 presigned URLs,可绕过控制台认证。
|
||||
|
||||
在横向移动、持久化或外传数据之前,了解 SageMaker 的组装方式至关重要。
|
||||
在你进行 pivot、persist 或 exfiltrate 数据之前,理解 SageMaker 的组成至关重要。
|
||||
|
||||
## 核心构建块
|
||||
## 核心构建模块
|
||||
|
||||
- **Studio Domains & Spaces**: Web IDE(JupyterLab、Code Editor、RStudio)。每个 domain 有共享的 EFS 文件系统和默认执行角色。
|
||||
- **Notebook Instances**: 托管的 EC2 实例,用于独立的 notebook;使用独立的执行角色。
|
||||
- **Studio Domains & Spaces**: Web IDE(JupyterLab、Code Editor、RStudio)。每个 domain 有一个共享的 EFS 文件系统和默认执行角色。
|
||||
- **Notebook Instances**: 用于独立 notebooks 的托管 EC2 实例;使用独立的执行角色。
|
||||
- **Training / Processing / Transform Jobs**: 短暂的容器,从 ECR 拉取代码并从 S3 获取数据。
|
||||
- **Pipelines & Experiments**: 编排的工作流,描述所有步骤、输入和输出。
|
||||
- **Models & Endpoints**: 打包的制品,通过 HTTPS endpoints 部署用于推理。
|
||||
- **Pipelines & Experiments**: 描述所有步骤、输入和输出的编排工作流。
|
||||
- **Models & Endpoints**: 打包的工件,通过 HTTPS endpoints 部署用于推理。
|
||||
- **Feature Store & Data Wrangler**: 用于数据准备和特征管理的托管服务。
|
||||
- **Autopilot & JumpStart**: 自动化 ML 和策划的模型目录。
|
||||
- **MLflow Tracking Servers**: 托管的 MLflow UI/API,使用预签名访问令牌。
|
||||
- **MLflow Tracking Servers**: 托管的 MLflow UI/API,使用 presigned access tokens。
|
||||
|
||||
每个资源都会引用执行角色、S3 存储位置、容器镜像以及可选的 VPC/KMS 配置——在枚举时务必收集所有这些信息。
|
||||
每个资源都会引用一个 execution role、S3 位置、container images,以及可选的 VPC/KMS 配置——在 enumeration 期间收集它们全部。
|
||||
|
||||
## 账户与全局元数据
|
||||
```bash
|
||||
@@ -39,9 +39,9 @@ aws sagemaker list-models --region $REGION --query 'Models[].ExecutionRoleArn' -
|
||||
# Generic tag sweep across any SageMaker ARN you know
|
||||
aws sagemaker list-tags --resource-arn <sagemaker-arn> --region $REGION
|
||||
```
|
||||
注意任何跨账户信任(执行角色或具有外部主体的 S3 存储桶)以及诸如 service control policies 或 SCPs 的基线限制。
|
||||
注意任何跨账户信任(execution roles 或 S3 buckets with external principals)以及基线限制,例如 服务控制策略(service control policies)或 SCPs。
|
||||
|
||||
## Studio 域、应用与共享空间
|
||||
## Studio 域、应用 & 共享空间
|
||||
```bash
|
||||
aws sagemaker list-domains --region $REGION
|
||||
aws sagemaker describe-domain --domain-id <domain-id> --region $REGION
|
||||
@@ -60,14 +60,14 @@ aws sagemaker describe-space --domain-id <domain-id> --space-name <space> --regi
|
||||
aws sagemaker list-studio-lifecycle-configs --region $REGION
|
||||
aws sagemaker describe-studio-lifecycle-config --studio-lifecycle-config-name <name> --region $REGION
|
||||
```
|
||||
需要记录:
|
||||
What to record:
|
||||
|
||||
- `DomainArn`, `AppSecurityGroupIds`, `SubnetIds`, `DefaultUserSettings.ExecutionRole`.
|
||||
- 挂载的 EFS (`HomeEfsFileSystemId`) 和 S3 主目录。
|
||||
- 生命周期脚本(通常包含引导凭据或用于推/拉的额外代码)。
|
||||
- 已挂载的 EFS (`HomeEfsFileSystemId`) 和 S3 主目录。
|
||||
- Lifecycle scripts(通常包含 bootstrap credentials 或用于 push/pull 的额外代码)。
|
||||
|
||||
> [!TIP]
|
||||
> Presigned Studio URLs 在权限过宽时可以绕过身份验证。
|
||||
> 如果授予范围过广,Presigned Studio URLs 可以绕过身份验证。
|
||||
|
||||
## Notebook Instances & Lifecycle Configs
|
||||
```bash
|
||||
@@ -78,11 +78,11 @@ aws sagemaker describe-notebook-instance-lifecycle-config --notebook-instance-li
|
||||
```
|
||||
Notebook 元数据会显示:
|
||||
|
||||
- 执行角色 (`RoleArn`)、是否允许直接访问互联网或仅限 VPC 模式。
|
||||
- S3 存储位置在 `DefaultCodeRepository`、`DirectInternetAccess`、`RootAccess`。
|
||||
- 生命周期脚本(用于凭证或持久化挂钩)。
|
||||
- 执行角色(`RoleArn`)、直接互联网访问 与 仅 VPC 模式。
|
||||
- 在 `DefaultCodeRepository`、`DirectInternetAccess`、`RootAccess` 中的 S3 存储位置。
|
||||
- 生命周期脚本,可能包含 credentials 或 persistence hooks。
|
||||
|
||||
## Training、Processing、Transform 和 Batch 作业
|
||||
## Training、Processing、Transform 与 Batch 作业
|
||||
```bash
|
||||
aws sagemaker list-training-jobs --region $REGION
|
||||
aws sagemaker describe-training-job --training-job-name <job> --region $REGION
|
||||
@@ -93,12 +93,12 @@ aws sagemaker describe-processing-job --processing-job-name <job> --region $REGI
|
||||
aws sagemaker list-transform-jobs --region $REGION
|
||||
aws sagemaker describe-transform-job --transform-job-name <job> --region $REGION
|
||||
```
|
||||
仔细检查:
|
||||
仔细审查:
|
||||
|
||||
- `AlgorithmSpecification.TrainingImage` / `AppSpecification.ImageUri` – 哪些 ECR 镜像已部署。
|
||||
- `InputDataConfig` & `OutputDataConfig` – S3 桶、前缀和 KMS 密钥。
|
||||
- `ResourceConfig.VolumeKmsKeyId`, `VpcConfig`, `EnableNetworkIsolation` – 确定网络或加密配置。
|
||||
- `HyperParameters` 可能 leak 环境凭证或连接字符串。
|
||||
- `AlgorithmSpecification.TrainingImage` / `AppSpecification.ImageUri` – 部署了哪些 ECR images。
|
||||
- `InputDataConfig` & `OutputDataConfig` – S3 存储桶、前缀和 KMS 密钥。
|
||||
- `ResourceConfig.VolumeKmsKeyId`, `VpcConfig`, `EnableNetworkIsolation` – 确定网络或加密策略。
|
||||
- `HyperParameters` 可能会 leak 环境机密或连接字符串。
|
||||
|
||||
## 管道、实验与试验
|
||||
```bash
|
||||
@@ -110,7 +110,7 @@ aws sagemaker list-experiments --region $REGION
|
||||
aws sagemaker list-trials --experiment-name <experiment> --region $REGION
|
||||
aws sagemaker list-trial-components --trial-name <trial> --region $REGION
|
||||
```
|
||||
Pipeline 定义详述每个步骤、关联角色、容器镜像和环境变量。试验组件通常包含训练工件 URIs、S3 日志和指标,这些暗示着敏感数据流动。
|
||||
Pipeline 定义详细列出每个步骤、关联角色、容器镜像和环境变量。试验组件通常包含训练工件 URI、S3 日志以及提示敏感数据流动的指标。
|
||||
|
||||
## 模型、端点配置与已部署端点
|
||||
```bash
|
||||
@@ -123,10 +123,11 @@ aws sagemaker describe-endpoint-config --endpoint-config-name <cfg> --region $RE
|
||||
aws sagemaker list-endpoints --region $REGION
|
||||
aws sagemaker describe-endpoint --endpoint-name <endpoint> --region $REGION
|
||||
```
|
||||
- 模型工件 S3 URIs (`PrimaryContainer.ModelDataUrl`) 和 推理容器镜像。
|
||||
- 端点的数据捕获配置(S3 bucket、KMS),用于可能的日志 exfil。
|
||||
Focus areas:
|
||||
- 模型工件的 S3 URIs (`PrimaryContainer.ModelDataUrl`) 和推理容器镜像。
|
||||
- 端点数据捕获配置(S3 bucket、KMS),用于可能的日志 exfil。
|
||||
- 使用 `S3DataSource` 或 `ModelPackage` 的多模型端点(检查跨账户打包)。
|
||||
- 附加到端点的网络配置和 security groups。
|
||||
- 网络配置和附加到端点的安全组。
|
||||
|
||||
## Feature Store, Data Wrangler & Clarify
|
||||
```bash
|
||||
@@ -141,9 +142,9 @@ aws sagemaker list-model-monitoring-schedule --region $REGION
|
||||
```
|
||||
安全要点:
|
||||
|
||||
- 在线特征存储会将数据复制到 Kinesis;检查 `OnlineStoreConfig.SecurityConfig.KmsKeyId` 和 VPC。
|
||||
- Data Wrangler 流程通常会嵌入 JDBC/Redshift 凭证或私有端点。
|
||||
- Clarify/Model Monitor 作业会将数据导出到 S3,可能对公众可读或可被跨账户访问。
|
||||
- Online feature stores 将数据复制到 Kinesis;检查 `OnlineStoreConfig.SecurityConfig.KmsKeyId` 和 VPC。
|
||||
- Data Wrangler flows 经常嵌入 JDBC/Redshift 凭证或私有端点。
|
||||
- Clarify/Model Monitor jobs 将数据导出到 S3,可能为对公众可读或可被跨账户访问。
|
||||
|
||||
## MLflow Tracking Servers, Autopilot & JumpStart
|
||||
```bash
|
||||
@@ -156,41 +157,41 @@ aws sagemaker describe-auto-ml-job --auto-ml-job-name <name> --region $REGION
|
||||
aws sagemaker list-jumpstart-models --region $REGION
|
||||
aws sagemaker list-jumpstart-script-resources --region $REGION
|
||||
```
|
||||
- MLflow tracking servers 存储实验和工件;预签名 URL 可能会暴露所有内容。
|
||||
- Autopilot jobs 会启动多个训练作业——枚举输出以查找隐藏数据。
|
||||
- JumpStart 参考架构可能会将特权角色部署到账户中。
|
||||
- MLflow 跟踪服务器存储实验和工件;presigned URLs 可能会暴露所有内容。
|
||||
- Autopilot 作业会启动多个 training jobs —— 枚举其输出以查找隐藏数据。
|
||||
- JumpStart 参考架构可能会在账户中部署有特权的角色。
|
||||
|
||||
## IAM & Networking Considerations
|
||||
## IAM 与网络注意事项
|
||||
|
||||
- 枚举附加到所有执行角色(Studio、notebooks、training jobs、pipelines、endpoints)的 IAM 策略。
|
||||
- 检查网络上下文:subnets、security groups、VPC endpoints。许多组织会隔离训练作业,但忘记限制出站流量。
|
||||
- 审查在 `ModelDataUrl`、`DataCaptureConfig`、`InputDataConfig` 中引用的 S3 桶策略,检查是否允许外部访问。
|
||||
- 枚举附加到所有执行角色的 IAM 策略(Studio、notebooks、training jobs、pipelines、endpoints)。
|
||||
- 检查网络上下文:subnets、security groups、VPC endpoints。许多组织会隔离 training jobs,但忘记限制出站流量。
|
||||
- 检查 S3 存储桶策略(在 `ModelDataUrl`、`DataCaptureConfig`、`InputDataConfig` 中引用)是否允许外部访问。
|
||||
|
||||
## Privilege Escalation
|
||||
## 权限提升
|
||||
|
||||
{{#ref}}
|
||||
../../aws-privilege-escalation/aws-sagemaker-privesc/README.md
|
||||
{{#endref}}
|
||||
|
||||
## Persistence
|
||||
## 持久性
|
||||
|
||||
{{#ref}}
|
||||
../../aws-persistence/aws-sagemaker-persistence/README.md
|
||||
{{#endref}}
|
||||
|
||||
## Post-Exploitation
|
||||
## 利用后操作
|
||||
|
||||
{{#ref}}
|
||||
../../aws-post-exploitation/aws-sagemaker-post-exploitation/README.md
|
||||
{{#endref}}
|
||||
|
||||
## Unauthorized Access
|
||||
## 未授权访问
|
||||
|
||||
{{#ref}}
|
||||
../../aws-unauthenticated-enum-access/aws-sagemaker-unauthenticated-enum/README.md
|
||||
{{#endref}}
|
||||
|
||||
## References
|
||||
## 参考资料
|
||||
|
||||
- [AWS SageMaker Documentation](https://docs.aws.amazon.com/sagemaker/latest/dg/whatis.html)
|
||||
- [AWS CLI SageMaker Reference](https://docs.aws.amazon.com/cli/latest/reference/sagemaker/index.html)
|
||||
|
||||
Reference in New Issue
Block a user