/

CVE-2026-34479

Severity:

HIGH RISK

(7.5)

Improper Output Encoding / Escaping in XML Layout for

CVE-2026-34479

Analyzed

Vulnerability type

Category:

Improper Output Encoding / Escaping

CWE:

CWE-116

Impact:

Log Integrity and Observability Disruption

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

The Apache Log4j 1-to-Log4j 2 bridge's Log4j1XmlLayout fails to escape characters that are forbidden in XML 1.0, resulting in malformed XML log output.

When such logs are consumed by standards-compliant XML parsers, downstream log processing systems may reject or drop affected records, leading to gaps in logging, monitoring, and security visibility.

Affected context

This vulnerability appears in environments that use the Apache Log4j 1-to-Log4j 2 bridge and rely on XML-formatted logs for downstream processing.

It primarily affects:

  • Systems that configure Log4j1XmlLayout directly in Log4j Core 2.
  • Deployments using the Log4j 1 configuration compatibility layer with org.apache.log4j.xml.XMLLayout as the layout class.

The issue becomes relevant when logs are consumed by XML 1.0–compliant parsers (e.g., log aggregators, SIEMs, or indexing pipelines) that strictly enforce XML well-formedness. In such setups, specific control characters or invalid code points in the log output can cause the entire document or record to be rejected.

Exploit preconditions

  • Attack surface: Log ingestion and processing pipeline that consumes Log4j XML logs.
  • Required access: Ability to influence log contents (e.g., by supplying user input that is logged).
  • Trigger point: Logging of values containing XML 1.0–forbidden characters (such as certain control characters) using the vulnerable XML layout.
  • Why exploitation is possible: The XML layout does not properly sanitize or escape disallowed characters before emitting XML, violating the XML 1.0 specification. Standards-compliant parsers must treat these documents as fatal errors and abort processing, which can be triggered by crafted or unexpected input flowing into logs.

Why this happens

The underlying issue is an improper output encoding/escaping flaw consistent with CWE-116.

XML log layouts are expected to produce well-formed XML, which includes escaping reserved characters and preventing the inclusion of forbidden code points. The Log4j1XmlLayout in the Log4j 1-to-2 bridge emits raw character data into XML elements or attributes without enforcing XML 1.0 character constraints.

As a result, when log messages, parameters, or contextual data contain characters disallowed by the XML standard, the generated XML becomes malformed. Downstream consumers that rely on strict XML parsing semantics encounter fatal parse errors and must reject the affected records, breaking assumptions about reliable, machine-readable logging.

Potential impact

  • Loss of specific log entries when downstream XML parsers reject malformed records.
  • Gaps in audit trails, monitoring, and forensic evidence that may hinder incident response.
  • Partial or complete failure of log indexing pipelines, leading to reduced searchability or delayed processing.
  • Potential evasion of detection by security monitoring systems that rely on complete, parseable logs.
  • Increased operational complexity due to intermittent log processing errors that are difficult to correlate with specific inputs.

General mitigation guidance

Mitigation revolves around ensuring that log output is well-formed XML and that layouts do not emit disallowed characters:

  • Prefer logging layouts that strictly conform to XML 1.0 and apply proper character escaping and filtering before output.
  • Introduce input normalization or sanitization for log fields that may contain control characters or untrusted data, reducing the chance of forbidden characters reaching the XML layout.
  • Configure logging to use alternative formats (e.g., JSON or plain text) when XML is not strictly required, especially for logs that incorporate untrusted or high-entropy data.
  • Enforce a separation between internal structured logging and user-facing or untrusted inputs, minimizing direct injection of raw input into structured log formats.
  • Apply least-privilege principles to log processing infrastructure, so that failures in parsing or indexing do not cascade into larger service disruptions.

These patterns help make log pipelines more resilient to malformed data, whether caused by implementation bugs or unexpected inputs.

How teams detect issues like this

Detecting this type of vulnerability and its effects can be approached from both code and operational perspectives:

  • Static analysis and configuration review:
  • Flag usages of Log4j1XmlLayout or org.apache.log4j.xml.XMLLayout in Log4j 2 configurations, especially in pipelines that consume logs as XML.
  • Review custom layouts or appenders for manual string concatenation or raw insertion of text into XML elements without centralized escaping routines.
  • Runtime monitoring and log pipeline diagnostics:
  • Monitor log aggregation and indexing systems for XML parsing errors, fatal parse exceptions, or sudden drops in ingest rates correlated with specific sources.
  • Implement validation checks at pipeline boundaries that detect malformed XML and record meta-events (e.g., "dropped malformed log record from host X") for troubleshooting.
  • Policy and CI/CD enforcement:
  • Use automated configuration linting or security policy checks in CI pipelines to prevent introduction of deprecated or unsafe layout classes.
  • Optionally leverage SAST/linters that understand logging frameworks to highlight risky logging patterns that directly embed untrusted values into structured formats like XML.

Sources

SourceLink
github.comgithub.com/apache/logging-log4j2/pull/4078
lists.apache.orglists.apache.org/thread/gd0hp6mj17rn3kj279vgy4p7kd4zz5on
logging.apache.orglogging.apache.org/cyclonedx/vdr.xml
logging.apache.orglogging.apache.org/log4j/2.x/migrate-from-log4j1.html
logging.apache.orglogging.apache.org/security.html#CVE-2026-34479
openwall.comopenwall.com/lists/oss-security/2026/04/10/8

Frequently asked

questions

It can be influenced remotely if an attacker can control or affect data that gets logged (for example, HTTP parameters, headers, or other user-supplied fields). By causing forbidden characters to be logged, they can indirectly impact downstream log processing.

Direct access to the logging infrastructure is not required. The primary requirement is the ability to generate inputs that are logged through the vulnerable XML layout. Any user or system capable of injecting such data into log messages could trigger malformed XML output.

The safest pattern is to use XML layouts that enforce proper XML 1.0 character rules, combined with centralized escaping and filtering of log output. Where possible, switch to supported, non-deprecated components and formats that guarantee well-formed structured logs without custom encoding logic.

To prevent related problems:

  • Adopt logging components that are actively maintained and standards-compliant.
  • Treat log output as structured data that must be encoded according to its format (XML, JSON, etc.), not as raw string concatenation.
  • Establish code review and static analysis practices that check for unsafe formatting and direct insertion of untrusted data into structured formats.
  • Regularly test log pipelines with fuzzed or edge-case input to confirm they remain robust and do not silently drop records due to parsing errors.
Find out what's already
exploitable in your codebase.