Skip to content

Commit dc218e4

Browse files
committed
compare webhook checksum using ConstantTimeCompare
1 parent ab96b49 commit dc218e4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

webhook/verifier.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package webhook
1616

1717
import (
1818
"crypto/sha256"
19+
"crypto/subtle"
1920
"encoding/base64"
2021
"io"
2122
"net/http"
@@ -59,7 +60,7 @@ func Receive(r *http.Request, provider auth.KeyProvider) ([]byte, error) {
5960
sha := sha256.Sum256(data)
6061
hash := base64.StdEncoding.EncodeToString(sha[:])
6162

62-
if claims.Sha256 != hash {
63+
if subtle.ConstantTimeCompare([]byte(claims.Sha256), []byte(hash)) != 1 {
6364
return nil, ErrInvalidChecksum
6465
}
6566

0 commit comments

Comments
 (0)