Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cognito doesn't invoke the "Define auth challenge" for users with enabled MFA #3876

Closed
alexgelman opened this issue Aug 20, 2019 · 10 comments
Closed
Assignees
Labels
Cognito Related to cognito issues Service Team Issues asked to the Service Team

Comments

@alexgelman
Copy link

alexgelman commented Aug 20, 2019

Describe the bug
If a user has software token MFA enabled, and the "Define auth challenge" trigger returned PASSWORD_VERIFIER as the challenge, cognito will not invoke the trigger for subsequent challenges. Instead it will challenge for the MFA token on its own and return tokens on a successful challenge.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new user pool with optional MFA authentication.
  2. Define a "Define auth challenge" trigger like the one in the documentation with the following challenges: PASSWORD_VERIFIER --> CUSTOM_CHALLENGE --> SOFTWARE_TOKEN_MFA
  3. Define the "Create auth challenge" and "Verify auth challenge response" triggers to lambdas similar to the ones in the documentation.
  4. Create a user and configure TOTP software MFA for the user.
  5. Call initiateAuth with AuthFlow=CUSTOM_AUTH and SRP_A auth parameters.
  6. Cognito triggers the "Define auth challenge" lambda and returns PASSWORD_VERIFIER challenge.
  7. Call respondToAuthChallenge with the SRP password verifier challenge response.
  8. Cognito verifies the challenge and responds with a SOFTWARE_TOKEN_MFA challenge instead of a CUSTOM_CHALLENGE challenge. The trigger lambda is not invoked.
  9. Calling respondToAuthChallenge with the MFA token results in a successful authentication and Cognito responding with tokens.

Expected behavior
Cognito verifies the PASSWORD_VERIFIER challenge response and triggers the "Define auth challenge" lambda to get the next challenge.

@elorzafe elorzafe added Cognito Related to cognito issues Service Team Issues asked to the Service Team bug Something isn't working labels Aug 20, 2019
@elorzafe
Copy link
Contributor

Hi @alexgelman,

Thanks for asking this. This is identified as a bug in Cognito service, and we will work on the prioritization for this issue.

@alexgelman
Copy link
Author

Hi, thanks for confirming this.

I have a related question, should it be possible to define the following challenge flow: CUSTOM_CHALLENGE --> SOFTWARE_TOKEN_MFA
I tried doing so, but after providing the token I received an exception with the message Invalid code or auth state for the user. even though the mfa code was valid.

@CactusFruit
Copy link

@elorzafe Do you have any update on this issue? As far as I can tell this means that Cognito currently does not honor software 2FA. Should we switch all users to SMS 2FA in the interim until this security hole is filled?

@arlogilbert
Copy link

arlogilbert commented Apr 30, 2020

How is it possible that AWS is ok with a gaping security hole for any customer who uses TOTP based MFA. How many customers are not aware of this hole? @elorzafe I see no reply to the last gentleman who asked for feedback.

@alexgelman
Copy link
Author

Maybe I should clarify that cognito does honor software MFA in this scenario.
The issue is that cognito ignores the user defined "Define auth challenge" trigger lambda if the first challenge returned by the lambda is PASSWORD_VERIFIER and MFA is configured for the user.

@clahoud
Copy link

clahoud commented Aug 12, 2020

Hi, thanks for confirming this.

I have a related question, should it be possible to define the following challenge flow: CUSTOM_CHALLENGE --> SOFTWARE_TOKEN_MFA
I tried doing so, but after providing the token I received an exception with the message Invalid code or auth state for the user. even though the mfa code was valid.

@alexgelman Were you able to fix this flow? I'm facing the same issue

@sammartinez sammartinez removed the bug Something isn't working label Feb 18, 2021
@sammartinez
Copy link
Contributor

@alexgelman Are you still looking for support on this issue? Please let us know

@iartemiev
Copy link
Member

@alexgelman,

We are going to close this issue since we have not heard from you.

Please let us know if you still need support and provide current steps to reproduce if you haven't already. We can reopen the issue to investigate further.

Thanks

@Famin42
Copy link

Famin42 commented Feb 14, 2022

same issue
still doesn't work, if you are users use MFA and later you decide to customize auth flow with this (Define Auth challenge Lambda trigger)

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Cognito Related to cognito issues Service Team Issues asked to the Service Team
Projects
None yet
Development

No branches or pull requests

9 participants