Skip to content

Commit

Permalink
Fix for KeyStore DoS vulnerability
Browse files Browse the repository at this point in the history
  • Loading branch information
Shashank-In committed Jun 2, 2020
1 parent 7671cab commit 8e8dd75
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions api/keystore/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,17 @@ func (ks *Keystore) CreateUser(_ *http.Request, args *CreateUserArgs, reply *Cre
return fmt.Errorf("user already exists: %s", args.Username)
}

if zxcvbn.PasswordStrength(args.Password, nil).Score < requiredPassScore {
return errWeakPassword
}
if len(args.Password) < 50 {
if zxcvbn.PasswordStrength(args.Password, nil).Score < requiredPassScore {
return errWeakPassword
}
}

if len(args.Password) >= 50 {
if zxcvbn.PasswordStrength(args.Password[:50], nil).Score < requiredPassScore {
return errWeakPassword
}
}

usr := &User{}
if err := usr.Initialize(args.Password); err != nil {
Expand Down

0 comments on commit 8e8dd75

Please sign in to comment.