πVulnerability #7: AWS Cognito Misconfiguration
Itβs not very uncommon that android apps nowadays use cloud services - and not very uncommon either that developers sometimes hardcode potentially sensitive API keys into the resources of the app. While browsing through strings.xml, we found the following key:
<string name="aws_Identity_pool_ID">us-east-1:7e9426f7-42af-4717-8689-00a9a4b65c1c</string>After a bit of researching, I found out the following documentation for AWS Cognito Identity Pools which are supposedly a means to provide temporary AWS credentials for unauthenticated users/guests.
If you ever find a suspicious API key in some bug bounty program or pentest, try to refer https://github.com/streaak/keyhacks in checking if the βleakedβ key has some potential security issues.
Using the mentioned keyhacks repo, I tried to read the part regarding AWS and tried to install awscli using the following command:
sudo apt-get install awscliTo test this vulnerability, I followed used the following writeup as a reference: https://blog.appsecco.com/exploiting-weak-configurations-in-amazon-cognito-in-aws-471ce761963
First step that we need to do is to extract AWS credentials (access_key, secret_key, session_token) from the identity-pool:
aws cognito-identity get-id --identity-pool-id us-east-1:7e9426f7-42af-4717-8689-00a9a4b65c1c --region us-east-1
aws cognito-identity get-credentials-for-identity --identity-id <identity-id-from-previous-command> --region us-east-1
Afterwhich, weβll use the following script (https://github.com/andresriancho/enumerate-iam) to enumerate permissions with the credentials that we have.

An interesting permission that we have is that we can list the s3 buckets. For it to work, we need to configure our credentials (Iβm using new creds here, I may have messed something up earlier):

We see two buckets, now letβs see what they contain:
Looks like some other player has left nothing for us lmao. To summarize the poc:
Extract AWS credentials (access_key, secret_key and session_token ) from the identity pool;
Enumerate permissions/roles for the credentials that you have;
Privesc by abusing permissions.
Last updated