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:
Kubernetes Submit Queue 2017-03-14 08:49:20 -07:00 committed by GitHub
commit 204540e36a

View File

@ -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
}