SNS Secrets (CloudGoat)

Quick note

  • often when we refer to attached policies it is simple a term meaning a policy (usually a managed policy) attached to a user, group, or role). So “attached policies” are typically managed policies linked to an entity.

Credentials & setting up

sns_user_access_key_id = AKIA4YM7GTDHMY5FW6QU
sns_user_secret_access_key = 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
#configure
aws configure --profile sns_user                                                            
AWS Access Key ID [None]: AKIA4YM7GTDHMY5FW6QU
AWS Secret Access Key [None]: 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
Default region name [None]: us-east-1
Default output format [None]: json

#whoami
aws sts get-caller-identity --profile sns_user    
{
    "UserId": "AIDA4YM7GTDHOBI5MDF3P",
    "Account": "877044078798",
    "Arn": "arn:aws:iam::877044078798:user/cg-sns-user-cgiduohs87zk12"
}

Enumeration

policy enumeration

1. List managed policies attached to the user

2. List inline policies

3. Retrieve the inline policy document

As we can see within the policy, our user does possess permissions related to SNS

What is SNS

SNS: Amazon’s Simple Notification Service

  • is a fully managed messaging service provided by AWS that enables you to send notifications or messages to a large number of subscribers or other services in a scalable and reliable way.

What does it actually do?

  • Publish messages to topics: Meaning you create SNS topics (think of them as communication channels)

  • Subscribers receive messages: Subscribers to the topic (”Communication Channel”) get the message. Subscribers can be:

    • Email Addresses

    • SMS

    • AWS Lambda functions (can be interesting)

    • HTTP/HTTPS endpoints (wenhooks)

    • SQS queues

    • Mobile push notification

With our current permissions, we can enumerate the Simple Notification Service

Enumerating SNS

1. List all SNS topics


2. List subscriptions for the topic

No subscriptions are currently associated with this topic.


3. View configuration details for the topic

We can see from the meta data there is a policy included for this particular topic

this is the access control policy for the SNS topic

security implications: this allows any (”*” Principal) to

  • subscribe to the topic

  • Receive messages from it

  • List who else is subscribed

This makes the topic (communication channel) publicly accessible and is generally insecure unless it’s intentional (i.e., for public event broadcasting)

Our next step would be to subscribe to this topic

  1. For the following, i will use a disposable email address from https://www.sharklasers.com/inbox

  2. Subscribing to the topic we found during the SNS enumeration

    To continue, we will need to log in to our email endpoint

after confirming, we can see within the AWS console that our endpoint is subscribed

  1. Now, if we wait a few minutes, we get an AWS notification message

    we can query API Gateway REST APIs to find possible paths

  1. Enumerating API resources

    With our newly found REST API we can enumerate for any sensitives API resources

    We can see we have discovered a API endpoint, before we can we can interact with the endpoint we still need to determine the deployment stage

    Awesome, we now have the stageName we can continue to query the /user-data endpoint

  2. Query the /user-data Endpoint with the API key

    we can craft a request with curl

    And with this, we have found both the flag and the admin's credentials.

Last updated