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

Fix for KeyStore DoS vulnerability #202

Merged
merged 6 commits into from
Jun 15, 2020

Conversation

Shashank-In
Copy link
Contributor

@codecov
Copy link

codecov bot commented Jun 2, 2020

Codecov Report

Merging #202 into master will decrease coverage by 0.04088%.
The diff coverage is 50.00000%.

@@                 Coverage Diff                 @@
##              master        #202         +/-   ##
===================================================
- Coverage   60.45730%   60.41642%   -0.04088%     
===================================================
  Files            246         246                 
  Lines          16663       16666          +3     
===================================================
- Hits           10074       10069          -5     
- Misses          5678        5683          +5     
- Partials         911         914          +3     

@swdee
Copy link
Contributor

swdee commented Jun 2, 2020

Duplicating the if function is not very nice and the change also requires code comments to say why the checked password is being truncated. Would you update the code to something like the following;

// As per issue https://github.com/ava-labs/gecko/issues/195 it was found the longer the length of password the slower zxcvbn.PasswordStrength() performs.  
// To avoid performance issues and DOS vector we only check the first 50 characters of the password.
checkPass := args.Password

if len(args.Password) > 50 {
    checkPass = args.Password[:50]
}

if zxcvbn.PasswordStrength(checkPass, nil).Score < requiredPassScore {
    return errWeakPassword
}

@swdee
Copy link
Contributor

swdee commented Jun 2, 2020

That would overflow too, so remove >= and change to just >, ie:

if len(args.Password) > 50 {
    checkPass = args.Password[:50]
}

@Shashank-In
Copy link
Contributor Author

Hi @swdee
Thank you for your advice. I tested the code in local and it works perfectly. I have updated the fix.

@swdee
Copy link
Contributor

swdee commented Jun 3, 2020

Almost there, the last thing needed is for the code changes to be run through go fmt to fix code alignment and formatting. See https://blog.golang.org/gofmt

Once that is done, it looks good from my eyes. Thanks for your testing an contribution.

@Shashank-In
Copy link
Contributor Author

Shashank-In commented Jun 3, 2020

@swdee Fixed it. Thanks again

Copy link
Contributor

@StephenButtolph StephenButtolph left a comment

Choose a reason for hiding this comment

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

Thank you both for looking into this. LGTM

@StephenButtolph StephenButtolph merged commit 58c9093 into ava-labs:master Jun 15, 2020
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.

None yet

3 participants