mirror of
https://github.com/bitwarden/server
synced 2025-12-06 00:03:34 +00:00
fix(vuln): Change OTP and Email providers to use time-constant equality operators
Co-authored-by: Todd Martin <106564991+trmartin4@users.noreply.github.com>
This commit is contained in:
@@ -65,7 +65,7 @@ public class EmailTokenProvider : IUserTwoFactorTokenProvider<User>
|
|||||||
}
|
}
|
||||||
|
|
||||||
var code = Encoding.UTF8.GetString(cachedValue);
|
var code = Encoding.UTF8.GetString(cachedValue);
|
||||||
var valid = string.Equals(token, code);
|
var valid = CoreHelpers.FixedTimeEquals(token, code);
|
||||||
if (valid)
|
if (valid)
|
||||||
{
|
{
|
||||||
await _distributedCache.RemoveAsync(cacheKey);
|
await _distributedCache.RemoveAsync(cacheKey);
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public class OtpTokenProvider<TOptions>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
var code = Encoding.UTF8.GetString(cachedValue);
|
var code = Encoding.UTF8.GetString(cachedValue);
|
||||||
var valid = string.Equals(token, code);
|
var valid = CoreHelpers.FixedTimeEquals(token, code);
|
||||||
if (valid)
|
if (valid)
|
||||||
{
|
{
|
||||||
await _distributedCache.RemoveAsync(cacheKey);
|
await _distributedCache.RemoveAsync(cacheKey);
|
||||||
|
|||||||
Reference in New Issue
Block a user