AWS - Redshift Privesc

支持 HackTricks

Redshift

有关 RDS 的更多信息,请查看:

AWS - Redshift Enum

redshift:DescribeClusters, redshift:GetClusterCredentials

有了这些权限,你可以获取所有集群的信息(包括名称和集群用户名)并获取访问凭证

# 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

潜在影响: 在数据库中查找敏感信息。

redshift:DescribeClusters, redshift:GetClusterCredentialsWithIAM

有了这些权限,你可以获取所有集群的信息获取访问它的凭证。 注意,postgres用户将拥有用于获取凭证的IAM身份的权限。

# 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

潜在影响: 在数据库中查找敏感信息。

redshift:DescribeClusters, redshift:ModifyCluster?

可以通过 aws cli 修改内部 postgres (redshift) 用户的主密码(我认为这些是你需要的权限,但我还没有测试过):

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

潜在影响: 在数据库中查找敏感信息。

访问外部服务

要访问以下所有资源,您需要指定要使用的角色。一个Redshift集群可以分配一个AWS角色列表,如果您知道ARN,可以使用这些角色,或者您可以设置为“default”以使用分配的默认角色。

此外,正如这里解释的,Redshift还允许连接角色(只要第一个角色可以假设第二个角色)以获得进一步访问权限,只需用逗号将它们分隔iam_role 'arn:aws:iam::123456789012:role/RoleA,arn:aws:iam::210987654321:role/RoleB';

Lambdas

正如https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_EXTERNAL_FUNCTION.html中解释的那样,可以通过如下方式从redshift调用lambda函数

CREATE EXTERNAL FUNCTION exfunc_sum2(INT,INT)
RETURNS INT
STABLE
LAMBDA 'lambda_function'
IAM_ROLE default;

S3

正如https://docs.aws.amazon.com/redshift/latest/dg/tutorial-loading-run-copy.html中所解释的,可以读写S3 buckets

# 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

https://docs.aws.amazon.com/redshift/latest/dg/t_Loading-data-from-dynamodb.html中所述,可以从dynamodb获取数据

copy favoritemovies
from 'dynamodb://ProductCatalog'
iam_role 'arn:aws:iam::0123456789012:role/MyRedshiftRole';

提供数据的Amazon DynamoDB表必须在与您的集群相同的AWS区域中创建,除非您使用REGION选项指定Amazon DynamoDB表所在的AWS区域。

EMR

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

参考资料

支持HackTricks

Last updated