mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
Merge pull request #43078 from jbeda/constant-token-compare
Automatic merge from submit-queue (batch tested with PRs 43022, 43078) Use constant time compare for bootstrap tokens This is a subtle security issue that should go in for 1.6 on a new feature (bootstrap tokens). ```release-note NONE ```
This commit is contained in:
commit
204540e36a
@ -20,6 +20,7 @@ Package bootstrap provides a token authenticator for TLS bootstrap secrets.
|
||||
package bootstrap
|
||||
|
||||
import (
|
||||
"crypto/subtle"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"time"
|
||||
@ -95,7 +96,7 @@ func (t *TokenAuthenticator) AuthenticateToken(token string) (user.Info, bool, e
|
||||
}
|
||||
|
||||
ts := getSecretString(secret, bootstrapapi.BootstrapTokenSecretKey)
|
||||
if ts != tokenSecret {
|
||||
if subtle.ConstantTimeCompare([]byte(ts), []byte(tokenSecret)) != 1 {
|
||||
return nil, false, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user