Skip to content

fix: stop logging plaintext new password in admin password reset - #918

Open
SeanDuggan wants to merge 10 commits into
OWASP:devfrom
SeanDuggan:dev#571-password-log
Open

SeanDuggan wants to merge 10 commits into
OWASP:devfrom
SeanDuggan:dev#571-password-log

Conversation

@SeanDuggan

Copy link
Copy Markdown
Member

Fixes #571

log.debug(newPass =  + newPassword) wrote the new plaintext password to the debug log whenever an admin reset a users password. Redact it, matching the existing pattern used for passwords elsewhere in the admin servlets (log the fact it was retrieved, not the value).

Fixes OWASP#571
@ismisepaul

Copy link
Copy Markdown
Member

that @SeanDuggan , the fix looks good. However, we should probably have an integration test for this.

I reckon put it in src/it/java/servlets/admin/userManagement/ChangeUserPasswordIT.java. Copy the setup from DeletePlayersIT / DowngradeAdminsIT (reset the database in @BeforeAll, Spring mock request and response, TestProperties.verifyTestAdmin plus TestProperties.loginDoPost to get an admin session and CSRF token). Then:

Create a target user with TestProperties.verifyTestUser and get its ID with Getter.getUserIdFromName.
Before calling doPost, attach a small capturing appender to the servlet’s logger and set it to DEBUG. That way the test doesn’t depend on the log config. This needs no new dependency, since log4j-core is already on the classpath:

Assert that the password was really updated (the response contains “password has been updated”). Then assert that no captured message contains the password. Without the first assertion the test could pass just because the servlet failed early.

@ismisepaul ismisepaul mentioned this pull request Oct 24, 2026
15 of 44 tasks
@ismisepaul ismisepaul moved this from Backlog to Next Release Backlog in Security Shepherd Oct 24, 2026
@ismisepaul ismisepaul added this to the 4.0.0 milestone Oct 24, 2026
@SeanDuggan SeanDuggan self-assigned this Oct 25, 2026
SeanDuggan and others added 3 commits October 29, 2026 09:50
Adds ChangeUserPasswordIT, which attaches a capturing appender to the
servlet logger at DEBUG, resets a user's password, and checks that the
update succeeded and the new password appears in no log message.
@SeanDuggan

Copy link
Copy Markdown
Member Author

Added an integration test for this fix: src/it/java/servlets/admin/userManagement/ChangeUserPasswordIT.java.

It signs in as an admin, creates a target user, and attaches a capturing log4j appender to the ChangeUserPassword logger at DEBUG. Then it resets the user's password through the servlet. It asserts that the response contains "password has been updated", so a servlet that bails out early can't pass. It also asserts that the debug output was captured. Finally it asserts that no captured log message contains the new password.

I checked it both ways locally against MariaDB 12.3. With the fix it passes. With log.debug("newPass = " + newPassword) put back, it fails with "New password was written to the log: newPass = ...". spotless:check passes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Next Release Backlog

Development

Successfully merging this pull request may close these issues.

[BUG] New Password Logged in Admin Password Reset Flow

2 participants