mirror of
https://github.com/grafana/grafana.git
synced 2025-01-10 08:03:58 -06:00
Merge pull request #3771 from bergquist/contant_time_comparison
fix(login): fix vulnerbility for timing attacks
This commit is contained in:
commit
9b42b33648
@ -3,6 +3,7 @@ package login
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"crypto/subtle"
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
m "github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
@ -56,7 +57,7 @@ func loginUsingGrafanaDB(query *LoginUserQuery) error {
|
||||
user := userQuery.Result
|
||||
|
||||
passwordHashed := util.EncodePassword(query.Password, user.Salt)
|
||||
if passwordHashed != user.Password {
|
||||
if subtle.ConstantTimeCompare([]byte(passwordHashed), []byte(user.Password)) != 1 {
|
||||
return ErrInvalidCredentials
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user