Avoid logging sensitive token values in TokenHelper#1738
Open
arunmanni-ai wants to merge 14 commits into
Open
Conversation
Redact form and session token values from WARN-level log output in TokenHelper.validToken() and update corresponding i18n message properties. Detailed diagnostics moved to DEBUG level with sanitized input.
Member
|
Please create a JIRA ticket to cover this change, thank you :) |
Updated warning message to include the form token in the log.
Author
|
Working on getting ASF JIRA access — will link the ticket once my account is approved. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
TokenHelper.validToken()detects a CSRF token mismatch, the WARN-level log message currently includes both the user-submitted form token and the server-side session token in cleartext. Since the session token is only removed on a successful match, the logged value remains a live credential — visible to anyone with access to application logs.This change redacts the token values from the WARN message and moves operational detail to DEBUG level with sanitized input, consistent with how
ParametersInterceptoralready handles user-supplied values elsewhere in the codebase.Changes
TokenHelper.javanew Object[0]replacesnew Object[]{ token, sessionToken })token != null,sessionToken != null), never the actual valuesnormalizeSpace()before logging, matching the pattern inParametersInterceptor(lines 221, 622)6 i18n properties files
struts-messages.properties,_en,_da,_de,_pl,_pt— removed{0}and{1}format specifiers fromstruts.internal.invalid.tokenWhat is NOT changed
equals()comparison and token-removal-on-success logicstruts.messages.invalid.token— separate key, untouched)validToken()and interceptor result codes