sanitize SD-ID and MSGID in Rfc5424Layout - #4235
Open
jmestwa-coder wants to merge 1 commit into
Open
Conversation
Parameter names and values were already sanitized, but MSGID and SD-ID went to the syslog record unmodified. A newline in a StructuredDataMessage type ends the record so the rest is read as a separate message, and a ']' in the id closes the structured data element early.
jmestwa-coder
force-pushed
the
rfc5424-sd-id-sanitize
branch
from
August 3, 2026 13:42
0f16517 to
a8180a7
Compare
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.
Rfc5424Layoutsanitizes SD-PARAM-NAME and escapes SD-PARAM-VALUE, but two neighboring fields of the same record go out unmodified:appendMessageIdappendsStructuredDataMessage.getType()raw, so a newline in the type ends the record and what follows is read as a separate syslog messageformatStructuredElementappends the SD-ID raw, so a]closes the element early and the remainder reads as a second, caller-controlled elementsetTypenor theStructuredDataIdconstructors check characters, only length, and both fields carry application datanew StructuredDataMessage("a] [forged@1 user=\"root", "login ok", "Audit\n<13>1 - - - - -")through aSyslogappender, before:after:
Same
?replacement #4073 introduced for parameter names. SD-ID reuses the SD-NAME rule since RFC 5424 gives both fields the same production, MSGID keeps the wider printable US-ASCII range its own rule allows. Lengths are left alone so callers that raiseStructuredDataId's 32 character limit keep working.Checklist
2.x./mvnw verifysucceeds (ran the build andRfc5424LayoutTestforlog4j-api,log4j-coreandlog4j-core-testlocally)src/changelog/.2.x.x