mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
docs/webhooks: use subtle.ConstantTimeCompare for comparing signatures
Fixes #6572 Signed-off-by: Andrew Dunham <andrew@du.nham.ca> Change-Id: I58610c46e0ea1d3a878f91d154db3da4de9cae00
This commit is contained in:
parent
74744b0a4c
commit
a6dff4fb74
@ -9,6 +9,7 @@
|
||||
import (
|
||||
"crypto/hmac"
|
||||
"crypto/sha256"
|
||||
"crypto/subtle"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
@ -95,7 +96,7 @@ func verifyWebhookSignature(req *http.Request, secret string) (events []event, e
|
||||
// Verify that the signatures match.
|
||||
var match bool
|
||||
for _, signature := range signatures[currentVersion] {
|
||||
if signature == want {
|
||||
if subtle.ConstantTimeCompare([]byte(signature), []byte(want)) == 1 {
|
||||
match = true
|
||||
break
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user