Skip to main content

Migration Guide: v1.8.1

Version 1.8.1 fixes the Cognito app client generated by the CLI. Existing projects must update their own infrastructure and deploy; upgrading npm packages alone does not protect an existing user pool.

Release Date​

2026-11-25

Step 1: Restrict the App Client and Deploy​

In infra/libs/infra-stack.ts, add the following writeAttributes configuration to apigw-client. It permits users to update only their own name attribute. Keep your other client settings.

const userPoolClient = new cdk.aws_cognito.UserPoolClient(this, 'apigw-client', {
userPool,
authFlows: { userPassword: true, userSrp: true },
writeAttributes: new cdk.aws_cognito.ClientAttributes().withStandardAttributes({
fullname: true,
}),
})

In ECS mode (config.ecs set), also add the following grant inside the existing if (!!taskRole) block so server-side user management has the same Cognito admin permissions as Lambda.

userPool.grant(
taskRole,
'cognito-idp:AdminGetUser',
'cognito-idp:AdminAddUserToGroup',
'cognito-idp:AdminCreateUser',
'cognito-idp:AdminDeleteUser',
'cognito-idp:AdminDisableUser',
'cognito-idp:AdminEnableUser',
'cognito-idp:AdminSetUserPassword',
'cognito-idp:AdminResetUserPassword',
'cognito-idp:AdminUpdateUserAttributes',
)

Deploy the infrastructure. The app client is updated in place with the same client ID; existing tokens stay valid. Review cdk diff for the client write attributes and ECS policy changes. Apply an explicit write allowlist to any additional app clients too.

Step 2: Temporary Remediation Without a Deploy​

If you cannot deploy immediately, set POOL_ID and CLIENT_ID for the affected client and use the following commands. update-user-pool-client resets omitted settings to defaults, so copy the existing settings and change only WriteAttributes; do not run it with only --write-attributes name.

aws cognito-idp describe-user-pool-client --user-pool-id "$POOL_ID" --client-id "$CLIENT_ID" \
--query UserPoolClient > client.json
jq '{UserPoolId, ClientId, ClientName, RefreshTokenValidity, AccessTokenValidity,
IdTokenValidity, TokenValidityUnits, ReadAttributes, ExplicitAuthFlows,
SupportedIdentityProviders, CallbackURLs, LogoutURLs, DefaultRedirectURI,
AllowedOAuthFlows, AllowedOAuthScopes, AllowedOAuthFlowsUserPoolClient,
AnalyticsConfiguration, PreventUserExistenceErrors, EnableTokenRevocation,
EnablePropagateAdditionalUserContextData, AuthSessionValidity, RefreshTokenRotation}
| with_entries(select(.value != null)) | .WriteAttributes = ["name"]' client.json > update.json
aws cognito-idp update-user-pool-client --cli-input-json file://update.json

Check describe-user-pool-client afterwards. Complete Step 1 as well: a later CDK deploy otherwise restores the old client configuration.

Step 3: Update Frontend Attribute Writes​

A user access token can now update only name. Direct UpdateUserAttributes calls (including Amplify updateUserAttributes) for other attributes fail with NotAuthorizedException. Move those edits to a server-side endpoint that authorizes the caller and uses AdminUpdateUserAttributes. Reading attributes is unchanged.

Step 4: Audit Every User​

Compare every user's custom:roles, custom:tenant, custom:groups and any other authorization attributes with your application's source of truth. An attacker may have added a non-admin role in another tenant or changed group membership. Set REGION and POOL_ID for the affected pool.

aws cognito-idp list-users --region "$REGION" --user-pool-id "$POOL_ID" --output json \
| jq -r '.Users[] | (.Attributes | from_entries) as $a
| [.Username, $a["custom:tenant"], $a["custom:roles"], $a["custom:groups"]] | @tsv'

Query CloudTrail in the user pool's region for recent calls. Event history covers 90 days; older events require a trail or CloudTrail Lake. Set START to an ISO 8601 timestamp. Absence of retained events does not prove that no abuse occurred.

aws cloudtrail lookup-events --region "$REGION" \
--lookup-attributes AttributeKey=EventName,AttributeValue=UpdateUserAttributes \
--start-time "$START"

Cognito records the caller's sub in additionalEventData, rather than the username, and may hide attribute values. Resolve each sub with list-users --filter "sub = \"<sub>\"". Correct unauthorized attributes and call admin-user-global-sign-out for affected users to revoke refresh sessions. Already-issued tokens can still carry escalated claims until they expire; global sign-out alone does not make offline JWT verification reject them.

Local Development​

The generated infra-local/cognito-local/db/clients.json now contains "WriteAttributes": ["name"]. However, cognito-local 3.23.x does not enforce this setting. Test frontend attribute updates against a deployed Cognito pool.

See Changelog v1.8.1 and secure app client configuration.