Skip to content

Conversation

@dbohannon
Copy link

TLDR; Call spec.clearPassword() to clear the internal copy of the password and prevent it from being leaked in memory.
See https://docs.oracle.com/javase/8/docs/api/javax/crypto/spec/PBEKeySpec.html

The plain text password is not cleared from memory after being used for key derivation in internalHash. This may leave sensitive data in memory longer than necessary, increasing the risk of exposure via memory dumps. After generating the secret key, we clear the sensitive password data from memory by refactoring the code to use a try-finally block that calls spec.clearPassword() after secretKeyFactory.generateSecret(spec).

Additional details and PoC available on request.

…d and prevent it from being leaked in memory.
@firaja firaja merged commit 18aaa55 into Password4j:master Aug 5, 2025
5 of 6 checks passed
@firaja firaja added this to the 1.8.5 milestone Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants