Summary
Apache Log4j Core's Rfc5424Layout in versions 2.21.0 through 2.25.3 can allow log injection when CRLF sequences are not properly escaped due to silently renamed configuration attributes.
Deployments using Rfc5424Layout directly with stream-based syslog (TCP or TLS) may emit unframed or unescaped log messages, enabling attackers to inject forged log entries or manipulate log structure if they can influence logged data.
Affected context
This vulnerability occurs in applications using Apache Log4j Core 2.21.0–2.25.3 that:
- Configure
Rfc5424Layoutdirectly for stream-based syslog logging, and - Rely on configuration attributes such as
newLineEscapeoruseTlsMessageFormatfor safe framing and newline escaping.
The issue is tied to configuration attributes that were silently renamed, so existing configurations may appear valid while no longer enforcing newline escaping or TLS-specific framing. Configurations using SyslogAppender are not affected, as its attribute names remained stable.
Exploit preconditions
- Attack surface: Log messages transmitted over syslog streams (TCP or TLS) using
Rfc5424Layoutdirectly. - Required access: Ability to control or significantly influence data that gets logged (e.g., user-supplied fields, headers, parameters, protocol messages).
- Trigger point: Emission of log events containing attacker-controlled input that includes newline (
\n) or CRLF (\r\n) sequences. - Why exploitation is possible: Due to undocumented configuration attribute renames, newline escaping and TLS message framing may silently stop working. This allows raw CRLF sequences and unframed messages to be sent, enabling an attacker to inject additional syslog records or modify log structure by crafting malicious log content.
Why this happens
The underlying problem is a combination of improper output neutralization and incorrect resolution of security-relevant configuration attributes.
From a CWE perspective:
- CWE-117 (Improper Output Neutralization for Logs): The
newLineEscapemechanism that should neutralize newline characters is effectively disabled when the attribute is silently renamed, so logging output may contain unescaped CRLF sequences. - CWE-684 (Incorrect Provision of Associated Security Function): The security behavior associated with configuration options (
newLineEscape,useTlsMessageFormat) is not correctly applied because the system no longer recognizes the documented attribute names. As a result, developers believe they have enabled safe framing and escaping, but the logging system operates in a less secure mode (unframed TCP with no newline escaping).
Abstractly, this reflects a bug class where security guarantees depend on configuration keys; changing or misaligning those keys silently disables protections while leaving configurations looking syntactically correct.
Potential impact
- Attackers may inject fake or misleading log entries by smuggling CRLF sequences into logged fields.
- Log records can be prematurely terminated, with additional attacker-controlled lines appended as separate syslog events.
- Security monitoring, compliance auditing, or incident response processes can be misled by fabricated or manipulated log messages.
- Correlation and parsing tools that assume well-framed RFC5424 or TLS-framed messages may misinterpret or discard records, degrading visibility.
- Downstream systems that trigger alerts or actions based on logs may be influenced by crafted entries.
General mitigation guidance
Mitigation generally focuses on restoring predictable, safe log framing and enforcing robust output neutralization for log data:
- Prefer logging configurations and appenders that apply safe defaults for framing and escaping (e.g., use higher-level appenders like
SyslogAppenderwhere feasible, rather than directRfc5424Layoutconfiguration). - Ensure that configuration attributes controlling newline escaping, framing, and TLS usage are correctly named, documented, and consistently applied across environments.
- Reduce trust in log input: validate, normalize, or constrain user-controllable fields before logging, especially when logs are fed into downstream security or analytics pipelines.
- Use layouts or encodings that inherently avoid ambiguous line breaks or framing issues (for example, structured formats like JSON in combination with transport-level framing).
- Apply least-privilege principles to systems that consume logs so that incorrect or malicious log content cannot directly compromise higher-value systems.
How teams detect issues like this
Detection efforts can focus on both configuration reviews and behavioral signals in log streams:
- Configuration analysis:
- Review Log4j configurations for use of
Rfc5424Layoutand confirm that security-relevant attributes (newline escaping, TLS framing) are valid for the version in use. - Use static configuration linters or CI checks to flag unknown or deprecated configuration attributes that appear to control security functions.
- Code review signals:
- Direct use of low-level layouts for syslog without accompanying tests or documentation about expected framing/escaping behavior.
- Assumptions in code comments or docs that rely on specific configuration keys for security-sensitive behavior.
- Runtime and log stream monitoring:
- Inspect syslog traffic for unexpected embedded newlines, multiple syslog messages within a single frame, or malformed RFC5424 records.
- Use log-parsing tools or SIEM rules to detect anomalies such as log entries starting with user-controlled prefixes or unexpected header patterns.
- Automated configuration and dependency review tools can assist by highlighting known risky combinations of Log4j versions and layout settings.

