mirror of
https://github.com/zadam/trilium.git
synced 2025-12-29 10:44:25 +01:00
fix(comparison): check all tokens, and do not short-circuit
This commit is contained in:
parent
6fdd418edd
commit
f45920e506
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user