Skip to content

Commit e5d2174

Browse files
committed
Set EnhancedEntropy as obsolete due to password shucking vulnerability
1 parent 1b590b9 commit e5d2174

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ services.AddScoped<IPasswordHasher<TUser>, BCryptPasswordHasher<TUser>>();
1414
### Options
1515

1616
- **WorkFactor**: int
17-
- **EnhancedEntropy**: bool
17+
- **EnhancedEntropy**: bool *(Obsolete due to [password shucking](https://www.scottbrady91.com/Authentication/Beware-of-Password-Shucking) vulnerability)*
1818

1919
Register with:
2020

src/ScottBrady91.AspNetCore.Identity.BCryptPasswordHasher/BCryptPasswordHasher.cs

+4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ public virtual string HashPassword(TUser user, string password)
3232
{
3333
if (string.IsNullOrWhiteSpace(password)) throw new ArgumentNullException(nameof(password));
3434

35+
#pragma warning disable 618
3536
return BCrypt.Net.BCrypt.HashPassword(password, options.WorkFactor, options.EnhancedEntropy);
37+
#pragma warning restore 618
3638
}
3739

3840
/// <summary>
@@ -48,7 +50,9 @@ public virtual PasswordVerificationResult VerifyHashedPassword(TUser user, strin
4850
if (string.IsNullOrWhiteSpace(hashedPassword)) throw new ArgumentNullException(nameof(hashedPassword));
4951
if (string.IsNullOrWhiteSpace(providedPassword)) throw new ArgumentNullException(nameof(providedPassword));
5052

53+
#pragma warning disable 618
5154
var isValid = BCrypt.Net.BCrypt.Verify(providedPassword, hashedPassword, options.EnhancedEntropy);
55+
#pragma warning restore 618
5256

5357
if (isValid && BCrypt.Net.BCrypt.PasswordNeedsRehash(hashedPassword, options.WorkFactor))
5458
{

src/ScottBrady91.AspNetCore.Identity.BCryptPasswordHasher/BCryptPasswordHasherOptions.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace ScottBrady91.AspNetCore.Identity
1+
using System;
2+
3+
namespace ScottBrady91.AspNetCore.Identity
24
{
35
/// <summary>
46
/// Options for BCryptPasswordHasher.
@@ -11,8 +13,10 @@ public class BCryptPasswordHasherOptions
1113
public int WorkFactor { get; set; } = 11;
1214

1315
/// <summary>
14-
/// Enables the use of SHA384 hashing prior to bcrypt hashing. Defaults to false
16+
/// Enables the use of SHA384 hashing prior to bcrypt hashing. This will make you vulnerable to password shucking. Defaults to false.
17+
/// https://www.scottbrady91.com/Authentication/Beware-of-Password-Shucking
1518
/// </summary>
19+
[Obsolete("Discouraged due to vulnerability to password shucking", false)]
1620
public bool EnhancedEntropy { get; set; } = false;
1721
}
1822
}

src/ScottBrady91.AspNetCore.Identity.BCryptPasswordHasher/ScottBrady91.AspNetCore.Identity.BCryptPasswordHasher.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1414
<IncludeSymbols>true</IncludeSymbols>
1515
<GenerateDocumentationFile>true</GenerateDocumentationFile>
16-
<Version>1.2.0</Version>
17-
<PackageReleaseNotes>Updated default work factor to 11. Added support for SuccessRehashNeeded. Updated bcrypt and ASP.NET Identity dependencies.</PackageReleaseNotes>
16+
<Version>1.3.0</Version>
17+
<PackageReleaseNotes>Set EnhancedEntropy as obsolete due to password shucking vulnerability</PackageReleaseNotes>
1818
</PropertyGroup>
1919

2020
<ItemGroup>

test/ScottBrady91.AspNetCore.Identity.BCryptPasswordHasher.Tests/BCryptPasswordHasherTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Microsoft.AspNetCore.Identity;
44
using Microsoft.Extensions.Options;
55
using Xunit;
6+
#pragma warning disable 618
67

78
namespace ScottBrady91.AspNetCore.Identity.BCryptPasswordHasher.Tests
89
{
@@ -50,7 +51,6 @@ public void HashPassword_WhenCalledMultipleTimesWithSamePlaintext_ExpectDifferen
5051
[Fact]
5152
public void HashPassword_WithCustomWorkFactor_ExpectVerifiableHash()
5253
{
53-
var random = new Random();
5454
var password = Guid.NewGuid().ToString();
5555

5656
options.WorkFactor = options.WorkFactor - 1;

0 commit comments

Comments
 (0)