mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-05 01:12:11 +01:00
ipn/localapi: use constant-time comparison for RequiredPassword (#17906)
Updates #cleanup Signed-off-by: Andrew Lytvynov <awly@tailscale.com>
This commit is contained in:
parent
9134440008
commit
888a5d4812
@ -7,6 +7,7 @@ package localapi
|
||||
import (
|
||||
"bytes"
|
||||
"cmp"
|
||||
"crypto/subtle"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@ -257,7 +258,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
http.Error(w, "auth required", http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
if pass != h.RequiredPassword {
|
||||
if subtle.ConstantTimeCompare([]byte(pass), []byte(h.RequiredPassword)) == 0 {
|
||||
metricInvalidRequests.Add(1)
|
||||
http.Error(w, "bad password", http.StatusForbidden)
|
||||
return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user