mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 23:52:50 -05:00
use fixed-time comparison of secrets (#1698)
This commit is contained in:
@ -893,7 +893,7 @@ namespace Bit.Core.Services
|
||||
return false;
|
||||
}
|
||||
|
||||
if (string.Compare(user.TwoFactorRecoveryCode, recoveryCode, true) != 0)
|
||||
if (!CoreHelpers.FixedTimeEquals(user.TwoFactorRecoveryCode, recoveryCode))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -921,5 +921,11 @@ namespace Bit.Core.Utilities
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool FixedTimeEquals(string input1, string input2)
|
||||
{
|
||||
return CryptographicOperations.FixedTimeEquals(
|
||||
Encoding.UTF8.GetBytes(input1), Encoding.UTF8.GetBytes(input2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user