Skip to content

HaveIBeenPwnedRestApiPasswordChecker implementations are not thread-safe #18234

@garvit-joshi

Description

@garvit-joshi

HaveIBeenPwnedRestApiPasswordChecker stores a single MessageDigest instance as a field and reuses it across all invocations of check(). Since MessageDigest is not thread-safe, concurrent calls can produce incorrect hash values.

To Reproduce

  1. Register HaveIBeenPwnedRestApiPasswordChecker as a singleton bean
  2. Call check() concurrently from multiple threads
  3. Hash computation becomes unreliable due to shared mutable state in MessageDigest

Expected behavior

The checker should produce correct results under concurrent access. A new MessageDigest instance should be created per invocation instead of reusing a shared instance.

Metadata

Metadata

Assignees

Labels

in: coreAn issue in spring-security-corestatus: duplicateA duplicate of another issuetype: bugA general bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions