The Apache Logging Services PMC has received the security report
referenced below. After analysis, we classified it as a BUG: a defect
with no security impact. In the interest of transparency, and so that
the community and other researchers can benefit from the analysis, we
are disclosing a summary of it.
Report reference (Logging Services PMC / security archive):
https://lists.apache.org/thread/p701hr6gomwy05v77zpf9zrz3qytfdml
Disposition: BUG -- not a vulnerability; no CVE; tracked in a public issue
TLP:CLEAR (this message may be redistributed without restriction)
The reporter was informed of this classification and of our intent to
publish this summary.
== Summary of the report ==
`Rfc5424Layout` escapes the characters `"`, `\` and `]` in structured
data parameter values (SD-PARAM-VALUE), as RFC 5424 requires, but
applies the replacement configured in `newLineEscape` after this
escaping. With the documented setting `newLineEscape="\n"`, a newline in
a `StructuredDataMessage` value or in an MDC value is emitted as `\n`,
with an unescaped backslash, contrary to section 6.3.3 of RFC 5424. The
reporter argued that strict receivers may reject the record and that a
replacement containing `]` or `"` could terminate the structured data
element early.
== PMC assessment ==
This is NOT a vulnerability, but a conformance bug.
RFC 5424, section 6.3.3, also specifies how receivers handle this
output: a backslash followed by any character other than `"`, `\` or `]`
is an invalid escape sequence, and the receiver MUST treat it as a
regular backslash followed by a regular character. A conforming receiver
therefore neither rejects the record nor terminates the value early: it
reads `A\nB`, which is exactly the value the operator asked for. No log
event is lost.
The characters that can break the structure are correctly escaped when
they come from untrusted content. The unescaped backslash comes from the
`newLineEscape` attribute, which is part of the configuration.
Configuration is trusted under our threat model, so the variant where
the replacement contains `]` or `"` depends entirely on an operator choice:
https://logging.apache.org/security.html#threat-common-sources-configuration
We recently handled a similar conformance error of `Rfc5424Layout`,
which only appears with a non-default setting, in the same way:
https://lists.apache.org/thread/fb8q0j78r5dpx6oko0xkvpkpr5jttfcq
== Fix ==
The newline replacement will be applied before the structured data
escaping, so that `newLineEscape="\n"` produces `A\\nB`, which
conforming receivers decode to `A\nB`. Receivers that do not decode RFC
5424 escapes will see `\\n` instead of `\n` in structured data values
after the fix. The free-form message part is not affected. The fix is
tracked in:
https://github.com/apache/logging-log4j2/issues/4464
== References ==
Threat model:
https://logging.apache.org/security.html
RFC 5424, section 6.3.3:
https://datatracker.ietf.org/doc/html/rfc5424#section-6.3.3
Security FAQ, syslog and RFC 5424 layouts:
https://logging.apache.org/security/faq.html#crlf-injection-rfc5424-layout
Questions and follow-up are welcome on this list or GitHub Discussions.
On behalf of the Apache Logging Services PMC,
Piotr P. Karwasz
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]