Skip to content

fix(e2e): disable self-registration in Cognito User Pools created by e2e tests#14898

Open
adrianjoshua-strutt wants to merge 1 commit into
devfrom
fix/disable-self-registration-e2e
Open

fix(e2e): disable self-registration in Cognito User Pools created by e2e tests#14898
adrianjoshua-strutt wants to merge 1 commit into
devfrom
fix/disable-self-registration-e2e

Conversation

@adrianjoshua-strutt
Copy link
Copy Markdown
Member

Description

All e2e test auth helper functions (addAuthWithDefault, addAuthWithDefaultSocial, addAuthWithGroupTrigger, etc.) now write an override.ts file that sets AdminCreateUserConfig.AllowAdminCreateUserOnly = true on the User Pool.

Motivation

This addresses a security finding (Mirador: palisade.udd.cognito.userpool.selfregistration_enabled) where Cognito User Pools created by e2e/canary tests allow public self-sign-up. Since all test user creation already uses AdminCreateUserCommand (never the SignUp API), disabling self-registration does not break any existing test functionality.

Changes

  • Added addAuthOverrideToDisableSelfSignup(cwd) helper function to packages/amplify-e2e-core/src/categories/auth.ts
  • Called this helper at the end of every addAuth* function that creates a new auth resource
  • The override uses the existing Amplify CLI override mechanism (typed override.ts written to the auth resource directory)
  • buildOverrideDir automatically picks up the override during amplify push

Impact

  • Tests that set up their own custom overrides (e.g., auth_6.test.ts) will simply overwrite this file with their own content — no conflict
  • The addAuthOverrideToDisableSelfSignup function is exported so tests adding auth through non-standard mechanisms can also call it explicitly
  • No changes to CLI product behavior — only the e2e test helpers are affected

Testing

  • TypeScript compilation verified (no new errors in auth.ts)
  • All changes are in the e2e test helper layer (amplify-e2e-core), so existing e2e test suites validate correctness

…e2e tests

All e2e test auth helper functions now write an override.ts file that sets
AdminCreateUserConfig.AllowAdminCreateUserOnly = true on the User Pool.

This addresses a security finding (Mirador: Cognito User Pool Self-Registration
Enabled) by ensuring test pools do not allow public self-sign-up. All test user
creation already uses AdminCreateUserCommand, so this change does not break any
existing test functionality.

The override is applied via the existing Amplify CLI override mechanism - a
typed override.ts file is written to the auth resource directory after the CLI
wizard completes. The buildOverrideDir function automatically picks this up
during amplify push.

Tests that set up their own custom overrides (e.g., auth_6.test.ts) will
simply overwrite this file with their own content, so there is no conflict.
@adrianjoshua-strutt adrianjoshua-strutt requested a review from a team as a code owner May 26, 2026 13:59
Copy link
Copy Markdown
Contributor

@sarayev sarayev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we validated that none of these tests need self-registration be enabled (any tests that test signUp functionality)?

@adrianjoshua-strutt
Copy link
Copy Markdown
Member Author

@sarayev Running the e2e tests should reveal this. But yes, some tests will need self registration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants