fix(comparison): check all tokens, and do not short-circuit

This commit is contained in:
perfectra1n 2025-12-21 09:26:20 -08:00
parent 6fdd418edd
commit f45920e506

View File

@ -85,13 +85,14 @@ function isValidAuthHeader(auth: string | undefined) {
return constantTimeCompare(etapiToken.tokenHash, authTokenHash);
} else {
// Check ALL tokens to prevent timing attacks - do not short-circuit
let isValid = false;
for (const etapiToken of becca.getEtapiTokens()) {
if (constantTimeCompare(etapiToken.tokenHash, authTokenHash)) {
return true;
isValid = true;
}
}
return false;
return isValid;
}
}