Amazon Cognito Misconfiguraitons

Amazon Cognito is a powerful service for managing user authentication and authorization in web and mobile applications. However, misconfigurations in Cognito can open the door to serious security risks, such as account takeovers, privilege escalations, and unauthorized access to AWS resources. In this blog post, we’ll explore common Cognito misconfigurations, provide a detailed table of test cases to identify vulnerabilities, and share practical tips to secure your Cognito setup. Whether you’re a developer, security professional, or DevOps engineer, this guide will help you strengthen your AWS environment.

Why Amazon Cognito Security Matters

Amazon Cognito simplifies user management with its user pools (for sign-up and sign-in) and identity pools (for AWS resource access). However, its flexibility can lead to misconfigurations that attackers exploit. Recent research, including case studies like the Flickr account takeover, highlights how seemingly minor oversights—such as allowing unverified email updates or exposing sensitive IDs—can lead to catastrophic breaches. By proactively testing for these issues, you can protect your application and users from such risks.

Common UserPools attacks

  • If application doesn't require email verification this may lead to duplicate registerationa, Account Overwrite and ATO attacks

  • If an email address is configured as an alias and a new user is created with a duplicate email, the alias can be transferred to the newer user, un-verifying the former user's email https://repost.aws/knowledge-center/cognito-email-verified-attribute

  • Attempt to authenticate without providing MFA after password entry.

  • Test if MFA can be disabled by a standard user (User unintentionally has the Wright permission).

  • The session is indeed checked to see if it lines up with the correct username.

  • The IdToken is checked to see if it’s valid (i.e., not expired).

  • However, there wasn’t any code linking that IdToken to the specific session or user. That’s because the dev who wrote the custom challenge logic didn’t do that last piece of validation!

https://boom-stinger-c76.notion.site/AWS-Cognito-Chaos-The-Major-Flaw-That-Let-Attackers-Takeover-User-Accounts-17953b6a0d6e80bf8a75f6d03654eecf

Test Third-Party Identity Providers (IdP) and Federation

  1. Forge a valid-looking JWT token (for OIDC) with your own IdP (e.g., a local Keycloak or Auth0 instance).

  2. Set the iss (issuer) to match the target’s expected IdP.

  3. Replace the aud with the expected Cognito client ID.

curl -X POST https://<domain>.auth.<region>.amazoncognito.com/oauth2/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=authorization_code&code=...&redirect_uri=..." \
  -H "Authorization: Bearer <your_forged_token>"
  • Forge or modify an identity assertion (SAML or JWT) that includes elevated claims like:

jsonCopyEdit"custom:role": "admin"
  • Use a test IdP you control to submit these claims.

  • Watch if Cognito accepts the claim and assigns privileges (e.g., in app or AWS permissions).

  • Try requesting excessive scopes:

httpCopyEditscope=openid profile email aws.cognito.signin.user.admin
  • Look at returned claims in id_token or access_token

Common IdentityPools attacks

IdentityPoolId 
Aws_cognito_identity_pool_id 
Identity Pool Id 
AWSCognitoIdentityService 
clientId 
client_id 
aws_user_pools_web_client_id

How to Use These Test Cases

To execute these test cases, you’ll need tools like the AWS CLI, Burp Suite for intercepting requests, or enumeration tools like enumerate-iam and ScoutSuite. Here’s a quick guide to get started:

  1. Set Up AWS CLI: Configure AWS CLI with temporary credentials or a test account to interact with Cognito APIs safely.

  2. Inspect Client-Side Code: Use browser developer tools or Burp Suite to check for exposed IDs like App Client ID or Identity Pool ID in JavaScript files or API responses.

  3. Test Attribute Updates: Use AWS CLI commands like admin-update-user-attributes to attempt modifying email or custom attributes, checking for verification bypasses or privilege escalations.

  4. Verify Permissions: Review your Cognito user pool settings in the AWS Management Console, ensuring that self-signup is disabled (if not needed) and attribute permissions are restricted.

For example, to test for the "Zero Click Account Takeover" vulnerability (inspired by the Flickr case), you can try updating a user’s email attribute with a case-sensitive variation (e.g., Victim@gmail.com vs. victim@gmail.com) using the following AWS CLI command:

aws cognito-idp admin-update-user-attributes --user-pool-id <your-user-pool-id> --username <username> --user-attributes Name="email",Value="Victim@gmail.com"

If the update succeeds without verification, your setup may be vulnerable.

Refrences

For further reading, check out these excellent resources:

Stay secure, and happy testing!

Last updated

Was this helpful?