Conversation
A debug record is its prefix line followed by the message and the stack trace, all starting at column 0, so a line break in a logged value - a user name, a RelayState, a SAML attribute - started a line that read as a record of its own. Every SLF4J logger in the product ends there too, through the openam-slf4j binding. DebugRecordFormat now lays out the record for both debug file writers and StdDebugFile.printError: a single-line message is written exactly as before, every line break inside a message continues the record indented, and every line of the stack trace is indented, the exception's own message included. A line at column 0 is a record's prefix and nothing else. FedletLogger writes each parameter on a braced line of its own; a line break inside one is now written as the escape it stands for, so it cannot leave the braces. The audit log's ELFFormatter already escapes line breaks.
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.
The
java/log-injectioncluster of the CodeQL medium triage (30 open alerts, plus the 5 dismissed earlier as "to be handled centrally"), handled centrally.Where the logged values end up
cassandra/Repo,ESIAProfileProvider,DefaultRealmLookup,IdTokenClaimGatherer). OpenAM ships its own SLF4J binding —openam-slf4j→AMDebugLogger→Debug— so every one of them is written byDebugFileImpl/StdDebugFile, the same two writers everyDebugcall in the product goes through. That is the one place to fix.com.sun.identity.log.Logger,OpenSSOLogger).ELFFormatter.processStringalready writes\r,\nand"in every field as escapes; nothing to change.FedletLogger(the fedlet's JUL logger; the server usesLogProvider), 4 are the STS instance publishers logging the response body of the OpenAM server they publish to.The debug record
A record is
prefix\nmessage[\nstack trace], every line at column 0, so a line break carried in a logged value — a user name, a RelayState, a SAML attribute — started a line that read as a record of its own.DebugRecordFormatnow lays out the record for both writers and forStdDebugFile.printError:\r\n,\r,\n, U+0085, U+2028, U+2029) continues the record indented by four spaces, so a multi-line dump stays readable and nothing logged starts a line at column 0;printStackTraceleaves is dropped (each trace used to be followed by a blank line).A line at column 0 is a record's prefix and nothing else. This also makes the per-site
forLoghelpers that were being added to individual warnings unnecessary for the line-break part.FedletLogger.formatMessagewrites each parameter on a braced line of its own; a line break inside one is now written as\r/\nso it cannot leave the braces.Verification
DebugRecordFormatTest(6) andFedletLoggerTest(3), each watched failing first.openam-shared1243 tests (DebugTest,DebugRotationTestwrite through the real writers),openam-core2130,openam-federation-library180 — 0 failures.Effect on the scan
CodeQL will keep reporting the 26 SLF4J sinks — the neutralisation happens below the sink, inside the binding — so after this lands they are dismissed with a reference to
DebugRecordFormat, together with the 3 audit-log sinks (ELFFormatter) and the 4 STS publisher lines (a response body from the OpenAM server itself, logged in the STS process).