Conversation
SonarQube flagged 17 Log Injection findings (javasecurity:S5145) where
user-controlled values (e.g. uuid, procDefKey, beanName, workerId,
urlString) are concatenated into log messages. All 17 share a single
root cause: the Log4j2 PatternLayout used the raw %m message converter,
which does not encode carriage-return / line-feed characters, allowing
an authenticated user to forge log lines via CRLF injection.
Rather than sanitizing each of the ~17 call sites individually, this
applies the Log4j2-native remediation centrally: wrap the message
converter in %encode{%m}{CRLF} on every PatternLayout. This encodes CR
and LF within the logged message only (auto-appended stack traces stay
outside the wrapper and remain readable), and covers all current and
future log statements.
Changed appenders:
- install/tomcat_lib/log4j2-tomcat.properties: rolling, artemis, CONSOLE
- cws-installer/src/main/resources/log4j2.properties: console
Clears SonarQube findings under IDS-10384. Config-only change; no Java
changes and no recompile required (monitorInterval reloads it live).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
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
SonarQube identified 17 Log Injection findings (
javasecurity:S5145, MINOR) across the codebase. Every one shares a single root cause: the Log4j2PatternLayoutused the raw%mmessage converter, which does not encode CR/LF characters. An authenticated user could therefore inject CRLF sequences into a user-controlled value (e.g.uuid,procDefKey,beanName,workerId,urlString,processVariables) and forge log lines.Instead of sanitizing each of the ~17 call sites individually (brittle, leaves gaps, and rots as new log statements are added), this applies the Log4j2-native remediation centrally: wrap the message converter in
%encode{%m}{CRLF}on everyPatternLayout.Why this approach
%encode{...}{CRLF}encodes CR/LF only within the message body; auto-appended stack traces sit outside the wrapper and stay readable/multi-line.monitorInterval = 30reloads the Tomcat config live.%encode{}{CRLF}is the documented OWASP/SonarQube fix for S5145; fully supported in the bundled Log4j 2.25.x.Changes
install/tomcat_lib/log4j2-tomcat.propertiesrolling,artemis,CONSOLEcws-installer/src/main/resources/log4j2.propertiesconsoleEach
... - %m%nbecomes... - %encode{%m}{CRLF}%n.SonarQube findings cleared (IDS-10384)
All 17
javasecurity:S5145findings, including:SchedulerDbService.java:500,SecurityService.java:124,SpringApplicationContext.java:74,78,WebUtils.java:83,180,RestService.java:523,542,854,1126,1568,1592,1605,1636,InitiatorsService.java:416,Scheduler.java:130,140.Testing
\r\nis encoded on a single line.Out of scope
The related SSRF finding (
javasecurity:S7044, IDS-10385) is not addressed here — it is being dispositioned as an accepted risk (see ticket).🤖 Generated with Claude Code