mirror of
https://github.com/zadam/trilium.git
synced 2026-03-11 14:40:22 +01:00
fix(comparison): check all tokens, and do not short-circuit
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user