CVE-2026-34478
Patch Available.
This Vulnerability has been fixed in the Never-Ending Support (NES) version offered by HeroDevs.
Overview
Apache Log4j 2 is a Java logging framework maintained by the Apache Logging Services project. It is a rewrite of Log4j 1 that separates a public logging API (log4j-api) from its implementation (log4j-core), and applications use it to route log events to files, sockets, databases, and other destinations. Its behavior is driven by configuration that binds appenders, layouts, and filters through a plugin system, with layouts such as PatternLayout, XmlLayout, and the separately-published JsonTemplateLayout (log4j-layout-template-json) controlling the serialized form of each event.
A content spoofing vulnerability (CVE-2026-34478) has been identified in the Rfc5424Layout of Apache Log4j Core, which allows attackers to inject forged syslog records through CRLF sequences in logged data. The layout silently ignores its documented newLineEscape and useTlsMessageFormat attributes, so newline escaping and RFC 5425 TLS framing that a user has configured are never applied.
Per OWASP: "Content spoofing, also referred to as content injection, 'arbitrary text injection' or virtual defacement, is an attack targeting a user made possible by an injection vulnerability in a web application."
This issue affects Apache Log4j 2 versions 2.21.0 through 2.25.3 and pre-release versions 3.0.0-beta1 through 3.0.0-beta3.
Details
Module Info
- Product: Apache Log4j 2
- Affected packages:
org.apache.logging.log4j:log4j-core - Affected versions: >=2.21.0 <2.25.4, >=3.0.0-beta1 <=3.0.0-beta3
- GitHub repository: https://github.com/apache/logging-log4j2
- Published packages: https://central.sonatype.com/artifact/org.apache.logging.log4j/log4j-core
- Package manager: Maven
- Fixed in:
- OSS Apache Log4j 2 2.25.4
- NES for Apache Log4j 2 2.24.3-log4j-2.24.5
Vulnerability Info
This High-severity vulnerability is found in the org.apache.logging.log4j:log4j-core package in Apache Log4j 2 versions 2.21.0 through 2.25.3 and 3.0.0-beta1 through 3.0.0-beta3. It affects applications that configure Rfc5424Layout directly, typically inside a Socket appender that ships RFC 5424 syslog messages to a stream-based (TCP or TLS) syslog collector.
Rfc5424Layout is configured through the plugin builder Rfc5424LayoutBuilder, and the plugin system binds a configuration attribute only when a builder field annotated with @PluginBuilderAttribute has the same name. In the affected versions the builder's fields do not use the attribute names that the Log4j documentation gives for this layout. The newline-escape string is bound only as escapeNL and the RFC 5425 switch only as useTLSMessageFormat, so the documented newLineEscape and useTlsMessageFormat attributes match no field and are dropped from the configuration:
public static class Rfc5424LayoutBuilder extends AbstractStringLayout.Builder<Rfc5424LayoutBuilder>
implements org.apache.logging.log4j.core.util.Builder<Rfc5424Layout> {
// ...
@PluginBuilderAttribute
private boolean includeNL;
@PluginBuilderAttribute
private String escapeNL;
// ...
@PluginBuilderAttribute
private String excludes;
@PluginBuilderAttribute
private String includes;
@PluginBuilderAttribute
private String required;
// ...
@PluginBuilderAttribute
private boolean useTLSMessageFormat;
// ...
}build() passes escapeNL and useTLSMessageFormat to the layout constructor unchanged. With newLineEscape ignored, the replacement string stays null, and the escaping helper that is applied to the message text, the exception text and the structured-data parameters returns its input untouched:
private String escapeNewlines(final String text, final String replacement) {
if (null == replacement) {
return text;
}
return NEWLINE_PATTERN.matcher(text).replaceAll(replacement);
}With useTlsMessageFormat ignored, toSerializable() never wraps the record in a TlsSyslogFrame, and the layout emits unframed messages as in RFC 6587 non-transparent framing, where a newline ends a record:
appendStructuredElements(buf, event);
appendMessage(buf, event);
if (useTlsMessageFormat) {
return new TlsSyslogFrame(buf.toString()).toString();
}
return buf.toString();In both cases a CR or LF character in attacker-influenced data that reaches a log event, such as a request parameter, a header value or an exception message, is written raw into the syslog stream. The receiving collector treats the text after the newline as a separate record, so an attacker can append forged syslog entries with an arbitrary priority, host name, application name and message, misleading log review, alerting and audit tooling that consumes the stream. Users of SyslogAppender are not affected, because that appender reads its own newLineEscape and newLine attributes and passes them to the layout builder through its setters.
Mitigation
Only recent versions of Apache Log4j 2 receive community support and updates. Older versions have no publicly available fixes for this vulnerability.
Users of the affected components should apply one of the following mitigations:
- Upgrade to a currently supported version of Apache Log4j 2. The OSS fix ships in Apache Log4j 2.25.4 and later.
- Leverage a commercial support partner like HeroDevs for post-EOL security support.
Credits
- Samuli Leinonen (finder)
