app: Use constant-time comparison for bearer token validation (#65204)

Replace direct string comparison with `checkSubjectToken`, which
uses `subtle.ConstantTimeCompare`. The other code path in
`auth.go` already used constant-time comparison via the same
function. Preserve the audit event on mismatch.
This commit is contained in:
Julia Ogris
2026-03-31 23:42:43 +00:00
committed by GitHub
parent 007dba012c
commit 5503cd391c
+1 -2
View File
@@ -468,8 +468,7 @@ func (h *Handler) getAppSessionFromCookie(r *http.Request) (types.WebSession, er
if err != nil {
return nil, trace.Wrap(err)
}
if ws.GetBearerToken() != subjectValue {
err := trace.AccessDenied("subject session token does not match")
if err := checkSubjectToken(subjectValue, ws); err != nil {
h.c.AuthClient.EmitAuditEvent(h.closeContext, &apievents.AuthAttempt{
Metadata: apievents.Metadata{
Type: events.AuthAttemptEvent,