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

amazon-cognito-identity-js: Error: Only radix 2, 4, 8, 16, 32 are supported #4430

Closed
julamb opened this issue Nov 20, 2019 · 26 comments
Closed
Assignees
Labels
to-be-reproduced Used in order for Amplify to reproduce said issue

Comments

@julamb
Copy link

julamb commented Nov 20, 2019

I am using amazon-cognito-identity-js (v 3.2.0).

My Cognito UserPool is set up to allow users to connect with a verified email address. Logging-in with a username or a verified email address works fine. However, when I try to log in with an unverified email address, I get the following error in the console. This happens whether or not the entered password is correct.

Error: Only radix 2, 4, 8, 16, 32 are supported
    at BigInteger.bnToString [as toString] (BigInteger.js:221)
    at BigInteger.bnToString [as toString] (BigInteger.js:219)
    at AuthenticationHelper.padHex (AuthenticationHelper.js:346)
    at AuthenticationHelper.getPasswordAuthenticationKey (AuthenticationHelper.js:288)
    at CognitoUser.js:301
    at Client.js:63
    at ZoneDelegate.invoke (zone-evergreen.js:359)
    at Object.onInvoke (core.js:39699)
    at ZoneDelegate.invoke (zone-evergreen.js:358)
    at Zone.run (zone-evergreen.js:124)

In the network tab, the corresponding call has the x-amz-target: AWSCognitoIdentityProviderService.InitiateAuth header, and the response is a json with ChallengeName: "PASSWORD_VERIFIER" and a ChallengeParameters object. I would share it here but I'm not sure if it contains sensitive information.

I'd be happy to provide more information if needed.

Edit

One thing that looks odd about the ChallengeParameters object, the salt seems to be a negative hex: SALT: "-55d8411fb9c566437988f9dca451e61d".

@julamb julamb added the to-be-reproduced Used in order for Amplify to reproduce said issue label Nov 20, 2019
@ofirm93
Copy link

ofirm93 commented Nov 21, 2019

The issue is fixed in #4427. Once it is merged should be resolved.

@vietduong-agilityio
Copy link

@ofirm93 Still got this error :((

@ebaizel
Copy link

ebaizel commented Nov 30, 2019

Is there a workaround until #4427 is fixed? Is there a prior version that works?

@reejeshkv
Copy link

Still got this error

@vietduong-agilityio
Copy link

@ebaizel There is a dump way for temp, you can open the BinInteger.js after install node and update bnToString(b) method into:
if (this.s < 0) return '-' + this.negate().toString(); => if (this.s < 0) return '-' + this.negate().toString(b);

@allencart
Copy link

allencart commented Dec 3, 2019

The issue is fixed in #4427. Once it is merged should be resolved.

Hi, I'm new to AWS Cognito and I'm having this issue as well. Would this fixed can cover my case also? Here's my policy, I don't even have an email and phone number attributes. Only username, password, and two custom attributes. I did a pre-sign up lamba trigger to autoConfirm the user.

Then when I tested my Cognito sign in lambda, these are the wrong credential combinations that I tried when the error occurs.

  1. Both username and password are wrong
  2. Only username is wrong, and the password is correct

@zcmgyu
Copy link

zcmgyu commented Dec 5, 2019

  1. Go to User Pools
  2. Open App Clients
  3. Click Show Details
  4. Change Prevent User Existence Errors from Enabled (Recommended) to Legacy

Screen Shot 2019-12-05 at 13 08 16

@tohjg
Copy link

tohjg commented Dec 20, 2019

Fixed in #4427. Release on @aws-amplify/auth@2.1.2

@Amplifiyer Amplifiyer assigned Amplifiyer and unassigned Amplifiyer Jan 6, 2020
@ericclemmons
Copy link
Contributor

@julamb @allencart We merged down fixes with #4520 and released it a few days later via 2.2.1.

This issue should be resolved, but if you update to latest and still experience problems, please comment so we can re-open!

@ericclemmons ericclemmons self-assigned this Jan 7, 2020
@JxDarkAngel
Copy link

I solved it by chasing the mail in lowercase letters and using a trim. and in the same way when reading the email that the user enters when they log in. It caused me the error if the user wrote it, it was case sensitive

@rilian
Copy link

rilian commented Feb 25, 2020

on "amazon-cognito-identity-js": "^3.2.0"

getting this error when trying to authenticate using email of user that does not exist in user pool

UPD: will check if updating to latest versions will fix the issue..

@ELRuncho
Copy link

Hi everyone. I starting getting this error when authenticating any user on my userpool, it started showing up all of a sudden. Has updating to the latest version worked for anybody here?

@Jmedders
Copy link

This is occurring on 2.2.6. It seems to be only specific strings of un-authenticated accounts that this occurs with. For example: rope@example.com yields a not authorized exception with message Incorrect username or password, but rope@examplez.com returns the error OP described (Only radix 2, 4, 8, 16, 32 are supported). Of course these are only examples, this is occurring for more valid looking emails.

Pulling off Auth from "aws-amplify": "^2.2.6",

@PaulBurridge
Copy link

I have tracked this down to an issue with Cognito returning a bad value for SALT which is for some reason preceded with a minus sign for some email addresses and not others.

I have raised a support ticket with AWS, but in the meantime would it be possible to handle this in Amplify by cleaning the SALT value? Assuming that would be quicker than waiting for a Cognito bug fix?

Request URL: https://cognito-idp.eu-west-1.amazonaws.com/
Request Method: POST
Status Code: 200 

# Bad Example (rope@examplez.com)

{
  "AuthFlow": "USER_SRP_AUTH",
  "ClientId": "1e...06",
  "AuthParameters": {
    "USERNAME": "rope@examplez.com",
    "SRP_A": "***"
  },
  "ClientMetadata": {}
}

{
  "ChallengeName":"PASSWORD_VERIFIER",
  "ChallengeParameters":{
    "SALT":"-7e6c89a610ada13205836f7df5da14db", <-- Minus sign in front of salt value????
    ...
  }
}

# Good Example (rope@example.com)

{
  "AuthFlow": "USER_SRP_AUTH",
  "ClientId": "1e...06",
  "AuthParameters": {
    "USERNAME": "rope@example.com",
    "SRP_A": "***"
  },
  "ClientMetadata": {}
}

{
  "ChallengeName":"PASSWORD_VERIFIER",
  "ChallengeParameters":{
    "SALT":"41d247d8d39d08e9e20ab9ad42c831ab",
    ...
  }
}

@Jmedders
Copy link

Jmedders commented May 5, 2020

Hey @ELRuncho, I updated from "aws-amplify": "^2.2.6", to "@aws-amplify/auth": "^3.2.6", and no longer have this error.

If anybody comes across this & is importing the entire aws-amplify package for simple auth as I was instead of the modularized @aws-amplify/auth and @aws-amplify/core I highly recommend trying the modular packages instead. Was able to reduce react bundle size by over 2mb with this simple change. See #122

@ELRuncho
Copy link

ELRuncho commented May 5, 2020

Hey @ELRuncho, I updated from "aws-amplify": "^2.2.6", to "@aws-amplify/auth": "^3.2.6", and no longer have this error.

If anybody comes across this & is importing the entire aws-amplify package for simple auth as I was instead of the modularized @aws-amplify/auth and @aws-amplify/core I highly recommend trying the modular packages instead. Was able to reduce react bundle size by over 2mb with this simple change. See #122

Yep, that did the trick for me

@tarasowski
Copy link

I'm receiving the same error message: "Only radix 2, 4, 8, 16, 32 are supported". It gets shown for usernames (emails) that are not registered / not in cognito user pool. "@aws-amplify/auth": "^2.1.6". The interesting thing is that I have two different apps and only in one of them the error gets shown! Both apps have the same version of aws-amplify. The first app shows the error: "Incorrect username or password", the other one shows "Only radix 2, 4, 8, 16, 32 are supported".

@katerinaonair
Copy link

I'm receiving the same error message: "Only radix 2, 4, 8, 16, 32 are supported". It gets shown for usernames (emails) that are not registered / not in cognito user pool. "@aws-amplify/auth": "^2.1.6". The interesting thing is that I have two different apps and only in one of them the error gets shown! Both apps have the same version of aws-amplify. The first app shows the error: "Incorrect username or password", the other one shows "Only radix 2, 4, 8, 16, 32 are supported".

I have the same issue

@ericclemmons
Copy link
Contributor

@katerinaonair If you've updated your aws-amplify dependencies to latest, cleared lock files, node_modules, and are still experiencing this, can you open a new issue with a reproducible sample?

@katerinaonair
Copy link

@katerinaonair If you've updated your aws-amplify dependencies to latest, cleared lock files, node_modules, and are still experiencing this, can you open a new issue with a reproducible sample?

Resolved with "Legacy", many thanks to @zcmgyu

@ericclemmons
Copy link
Contributor

Thanks for the update @katerinaonair!

@Saeger
Copy link

Saeger commented Aug 11, 2020

Hi @katerinaonair , just came here to remind you that switching to "Legacy" isn't the best option other than bumping the lib to the latest version which fixes the issue.
The reason is, because the "Legacy" User Errors will send too much information from the Cognito pool endpoint, that could potentially make attacker's life easier. I know this sounds "too much preventive", but updating the library seems safer here.

@paulie4
Copy link

paulie4 commented Oct 15, 2020

@PaulBurridge-kcom, in your comment, you said you raised a support ticket with AWS. Did they ever get back to you about whether the negative salt value is actually correct?

@PaulBurridge
Copy link

@paulie4 AWS Support said they had fixed this in Amplify, basically they altered Amplify to work around the Coignito bug without acknowledging (or fixing) the bug in Cognito.

@paulie4
Copy link

paulie4 commented Oct 15, 2020

Yeah, the negative salt value definitely seems like a bug, and it looks like the code in this project is just working by luck. AuthenticationHelper.getPasswordAuthenticationKey() calls AuthenticationHelper.hexHash(), which does new util.Buffer(hexStr, 'hex'), and a variable name of hexStr for a buffer would imply that there should not be any characters besides 0-9 and a-f in the string. The lucky thing is that Buffer.hexWrite() calls parseInt(string.substr(i * 2, 2), 16), and the negative symbol is the second character, so parseInt() just ignores it.

@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 Oct 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
to-be-reproduced Used in order for Amplify to reproduce said issue
Projects
None yet
Development

No branches or pull requests