Skip to content

Commit 742f022

Browse files
committed
#62732 Fix password validation in PasswordHasher`1: add check for upper bound for salt size before allocation an array
1 parent 1b5d54e commit 742f022

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Identity/Extensions.Core/src/PasswordHasher.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ private static bool VerifyHashedPasswordV2(byte[] hashedPassword, string passwor
249249

250250
private static bool VerifyHashedPasswordV3(byte[] hashedPassword, string password, out int iterCount, out KeyDerivationPrf prf)
251251
{
252+
const int MaxSaltSize = 1024 * 8; // 8 KiB
253+
252254
iterCount = default(int);
253255
prf = default(KeyDerivationPrf);
254256

@@ -260,7 +262,7 @@ private static bool VerifyHashedPasswordV3(byte[] hashedPassword, string passwor
260262
int saltLength = (int)ReadNetworkByteOrder(hashedPassword, 9);
261263

262264
// Read the salt: must be >= 128 bits
263-
if (saltLength < 128 / 8)
265+
if (saltLength < 128 / 8 || saltLength > MaxSaltSize)
264266
{
265267
return false;
266268
}

0 commit comments

Comments
 (0)