Severity: High
Category
Authentication Failures (OWASP A07)
Files
internal/httpapi/middleware/basic_auth.go:39
Description
Password comparison uses == which short-circuits on the first mismatched byte. Leaks timing information about how many leading bytes match. No rate limiting makes this worse since an attacker can run many attempts quickly.
// line 39
if username == u.Username && password == u.Password {
Fix
import "crypto/subtle"
usernameMatch := subtle.ConstantTimeCompare([]byte(username), []byte(u.Username))
passwordMatch := subtle.ConstantTimeCompare([]byte(password), []byte(u.Password))
if usernameMatch == 1 && passwordMatch == 1 {
authorized = true
break
}
Severity: High
Category
Authentication Failures (OWASP A07)
Files
internal/httpapi/middleware/basic_auth.go:39Description
Password comparison uses
==which short-circuits on the first mismatched byte. Leaks timing information about how many leading bytes match. No rate limiting makes this worse since an attacker can run many attempts quickly.Fix