AWS - SageMaker Enumerazione

Reading time: 8 minutes

tip

Impara e pratica il hacking AWS:HackTricks Training AWS Red Team Expert (ARTE)
Impara e pratica il hacking GCP: HackTricks Training GCP Red Team Expert (GRTE) Impara e pratica il hacking Azure: HackTricks Training Azure Red Team Expert (AzRTE)

Supporta HackTricks

Service Overview

Amazon SageMaker è la piattaforma managed di AWS per machine learning che mette insieme notebooks, infrastruttura di training, orchestrazione, registries e managed endpoints. Una compromissione delle risorse SageMaker tipicamente fornisce:

  • Ruoli di esecuzione IAM a lunga durata con ampio accesso a S3, ECR, Secrets Manager o KMS.
  • Accesso a dataset sensibili memorizzati in S3, EFS o all'interno dei feature store.
  • Presenza di rete all'interno delle VPC (Studio apps, training jobs, endpoints).
  • presigned URLs ad alto privilegio che eludono l'autenticazione della console.

Capire come SageMaker è assemblato è fondamentale prima di pivot, persist o exfiltrate dati.

Core Building Blocks

  • Studio Domains & Spaces: Web IDE (JupyterLab, Code Editor, RStudio). Ogni dominio ha un file system EFS condiviso e un ruolo di esecuzione predefinito.
  • Notebook Instances: EC2 managed per notebook standalone; usano ruoli di esecuzione separati.
  • Training / Processing / Transform Jobs: Container effimeri che pullano codice da ECR e dati da S3.
  • Pipelines & Experiments: Workflow orchestrati che descrivono tutti i passaggi, input e output.
  • Models & Endpoints: Artefatti confezionati deployati per inference via HTTPS endpoints.
  • Feature Store & Data Wrangler: Servizi managed per la preparazione dei dati e la gestione delle feature.
  • Autopilot & JumpStart: ML automatizzato e catalogo di modelli curati.
  • MLflow Tracking Servers: UI/API MLflow managed con presigned access tokens.

Ogni risorsa fa riferimento a un execution role, location S3, container images e configurazioni opzionali VPC/KMS—capture all of them durante enumeration.

Account & Global Metadata

bash
REGION=us-east-1
# Portfolio status, used when provisioning Studio resources
aws sagemaker get-sagemaker-servicecatalog-portfolio-status --region $REGION

# List execution roles used by models (extend to other resources as needed)
aws sagemaker list-models --region $REGION --query 'Models[].ExecutionRoleArn' --output text | tr '	' '
' | sort -u

# Generic tag sweep across any SageMaker ARN you know
aws sagemaker list-tags --resource-arn <sagemaker-arn> --region $REGION

Segnala eventuali trust cross-account (execution roles o S3 buckets con external principals) e restrizioni di base come service control policies o SCPs.

Studio Domains, Apps & Spazi Condivisi

bash
aws sagemaker list-domains --region $REGION
aws sagemaker describe-domain --domain-id <domain-id> --region $REGION
aws sagemaker list-user-profiles --domain-id-equals <domain-id> --region $REGION
aws sagemaker describe-user-profile --domain-id <domain-id> --user-profile-name <profile> --region $REGION

# Enumerate apps (JupyterServer, KernelGateway, RStudioServerPro, CodeEditor, Canvas, etc.)
aws sagemaker list-apps --domain-id-equals <domain-id> --region $REGION
aws sagemaker describe-app --domain-id <domain-id> --user-profile-name <profile> --app-type JupyterServer --app-name default --region $REGION

# Shared collaborative spaces
aws sagemaker list-spaces --domain-id-equals <domain-id> --region $REGION
aws sagemaker describe-space --domain-id <domain-id> --space-name <space> --region $REGION

# Studio lifecycle configurations (shell scripts at start/stop)
aws sagemaker list-studio-lifecycle-configs --region $REGION
aws sagemaker describe-studio-lifecycle-config --studio-lifecycle-config-name <name> --region $REGION

Cosa registrare:

  • DomainArn, AppSecurityGroupIds, SubnetIds, DefaultUserSettings.ExecutionRole.
  • EFS montati (HomeEfsFileSystemId) e directory home S3.
  • Script di lifecycle (spesso contengono credenziali di bootstrap o codice aggiuntivo per push/pull).

tip

Presigned Studio URLs possono aggirare l'autenticazione se concessi in modo troppo ampio.

Notebook Instances & Lifecycle Configs

bash
aws sagemaker list-notebook-instances --region $REGION
aws sagemaker describe-notebook-instance --notebook-instance-name <name> --region $REGION
aws sagemaker list-notebook-instance-lifecycle-configs --region $REGION
aws sagemaker describe-notebook-instance-lifecycle-config --notebook-instance-lifecycle-config-name <cfg> --region $REGION

I metadati del notebook rivelano:

  • Ruolo di esecuzione (RoleArn), accesso diretto a Internet vs. modalità solo VPC.
  • Posizioni S3 in DefaultCodeRepository, DirectInternetAccess, RootAccess.
  • Script di lifecycle per credenziali o hook di persistenza.

Training, Processing, Transform e Batch Jobs

bash
aws sagemaker list-training-jobs --region $REGION
aws sagemaker describe-training-job --training-job-name <job> --region $REGION

aws sagemaker list-processing-jobs --region $REGION
aws sagemaker describe-processing-job --processing-job-name <job> --region $REGION

aws sagemaker list-transform-jobs --region $REGION
aws sagemaker describe-transform-job --transform-job-name <job> --region $REGION
  • AlgorithmSpecification.TrainingImage / AppSpecification.ImageUri – quali immagini ECR sono distribuite.
  • InputDataConfig & OutputDataConfig – bucket S3, prefissi e chiavi KMS.
  • ResourceConfig.VolumeKmsKeyId, VpcConfig, EnableNetworkIsolation – determinare la postura di rete o di crittografia.
  • HyperParameters possono causare leak di segreti d'ambiente o stringhe di connessione.

Pipelines, Experiments & Trials

bash
aws sagemaker list-pipelines --region $REGION
aws sagemaker list-pipeline-executions --pipeline-name <pipeline> --region $REGION
aws sagemaker describe-pipeline --pipeline-name <pipeline> --region $REGION

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

Le definizioni delle pipeline descrivono ogni passaggio, i ruoli associati, le immagini dei container e le variabili d'ambiente. I componenti dei trial spesso contengono URI degli artefatti di addestramento, log S3 e metriche che suggeriscono il flusso di dati sensibili.

Modelli, Configurazioni degli Endpoint e Endpoint Distribuiti

bash
aws sagemaker list-models --region $REGION
aws sagemaker describe-model --model-name <name> --region $REGION

aws sagemaker list-endpoint-configs --region $REGION
aws sagemaker describe-endpoint-config --endpoint-config-name <cfg> --region $REGION

aws sagemaker list-endpoints --region $REGION
aws sagemaker describe-endpoint --endpoint-name <endpoint> --region $REGION

Aree di interesse:

  • URI S3 degli artefatti del modello (PrimaryContainer.ModelDataUrl) e immagini dei container di inference.
  • Configurazione di data capture dell'endpoint (S3 bucket, KMS) per possibile log exfil.
  • Endpoint multi-model che utilizzano S3DataSource o ModelPackage (verificare il packaging cross-account).
  • Config di rete e security groups associati agli endpoint.

Feature Store, Data Wrangler & Clarify

bash
aws sagemaker list-feature-groups --region $REGION
aws sagemaker describe-feature-group --feature-group-name <feature-group> --region $REGION

aws sagemaker list-data-wrangler-flows --region $REGION
aws sagemaker describe-data-wrangler-flow --flow-name <flow> --region $REGION

aws sagemaker list-model-quality-job-definitions --region $REGION
aws sagemaker list-model-monitoring-schedule --region $REGION

Considerazioni sulla sicurezza:

  • Gli online feature store replicano i dati su Kinesis; verificare OnlineStoreConfig.SecurityConfig.KmsKeyId e la VPC.
  • I flussi di Data Wrangler spesso incorporano credenziali JDBC/Redshift o endpoint privati.
  • I job di Clarify/Model Monitor esportano dati in S3 che potrebbero essere leggibili pubblicamente o accessibili da account diversi.

MLflow Tracking Servers, Autopilot & JumpStart

bash
aws sagemaker list-mlflow-tracking-servers --region $REGION
aws sagemaker describe-mlflow-tracking-server --tracking-server-name <name> --region $REGION

aws sagemaker list-auto-ml-jobs --region $REGION
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 store experiments and artefacts; presigned URLs can expose everything.
  • Autopilot jobs spin multiple training jobs—enumerate outputs for hidden data.
  • Le architetture di riferimento JumpStart possono distribuire ruoli privilegiati nell'account.

Considerazioni su IAM e Networking

  • Enumerare le IAM policies allegate a tutti i ruoli di esecuzione (Studio, notebooks, training jobs, pipelines, endpoints).
  • Verificare i contesti di rete: subnets, security groups, VPC endpoints. Molte organizzazioni isolano i training jobs ma dimenticano di limitare il traffico in uscita.
  • Riesaminare le S3 bucket policies referenziate in ModelDataUrl, DataCaptureConfig, InputDataConfig per accesso esterno.

Privilege Escalation

AWS - Sagemaker Privesc

Persistence

Aws Sagemaker Persistence

Post-Exploitation

AWS - SageMaker Post-Exploitation

Unauthorized Access

AWS - SageMaker Unauthenticated Enum

References

tip

Impara e pratica il hacking AWS:HackTricks Training AWS Red Team Expert (ARTE)
Impara e pratica il hacking GCP: HackTricks Training GCP Red Team Expert (GRTE) Impara e pratica il hacking Azure: HackTricks Training Azure Red Team Expert (AzRTE)

Supporta HackTricks