CVE-2026-49844

Denial of Service
Content Spoofing
Affects
Apache Log4j 2
in
Apache Log4j
No items found.
Versions
>=2.13.1 <=2.25.4, 2.26.0

Patch Available.

Exclamation circle icon
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 Denial of Service (DoS) vulnerability (CVE-2026-49844) has been identified in MapMessageJsonFormatter, the internal formatter in the log4j-api artifact that backs MapMessage.asJson(), which allows attackers who can place a non-finite IEEE 754 value (NaN, Infinity, or -Infinity) into a logged MapMessage to emit bare NaN, Infinity, and -Infinity tokens into the serialized output. RFC 8259 does not permit those tokens, so any strict downstream parser rejects the enclosing document. This is the incomplete-fix follow-up to CVE-2026-34481: that advisory covered only JsonWriter in the log4j-layout-template-json artifact, leaving the log4j-api formatter that serves the JsonTemplateLayout message resolver and MapMessage.getFormattedMessage(new String[]{"JSON"}) still affected.

Per OWASP: "The Denial of Service (DoS) attack is focused on making a resource (site, application, server) unavailable for the purpose it was designed. There are many ways to make a service unavailable for legitimate users by manipulating network packets, programming, logical, or resources handling vulnerabilities, among others." Here the resource denied is the logging pipeline downstream of the application: a collector that strict-parses each record drops the malformed line, routes it to a dead-letter destination, or back-pressures at the agent, so the record that would have evidenced the attacker's activity never reaches the SIEM or audit store.

This issue affects the JSON serialization of MapMessage values in the log4j-api artifact of Apache Log4j 2.

Details

Module Info

Vulnerability Info

This Medium-severity vulnerability is found in the log4j-api package in the MapMessage JSON serialization path of Apache Log4j 2.

An application is exposed when both of the following hold:

  • The deployed configuration uses a layout that relies on MapMessage.asJson() or MapMessage.getFormattedMessage(new String[]{"JSON"}), such as the message resolver of JsonTemplateLayout.
  • The application logs a MapMessage (or a StructuredDataMessage, which extends it) carrying a floating-point value that originates from untrusted input.

When those conditions are met, the value reaches MapMessageJsonFormatter and is appended to the output buffer with no check for finiteness. StringBuilder#append(double) and StringBuilder#append(float) are specified as appending Double.toString(value) and Float.toString(value), which render non-finite inputs as the bare identifiers NaN, Infinity, and -Infinity. Those identifiers are not quoted, so they leave the formatter as invalid JSON number tokens.

Prior to the fix, the scalar path read:

private static void formatNumber(final StringBuilder sb, final Number number) {
    if (number instanceof BigDecimal) {
        final BigDecimal decimalNumber = (BigDecimal) number;
        sb.append(decimalNumber.toString());
    } else if (number instanceof Double) {
        final double doubleNumber = (Double) number;
        sb.append(doubleNumber);
    } else if (number instanceof Float) {
        final float floatNumber = (float) number;
        sb.append(floatNumber);
    } else if (number instanceof Byte
            || number instanceof Short
            || number instanceof Integer
            || number instanceof Long) {
        final long longNumber = number.longValue();
        sb.append(longNumber);
    } else {
        final long longNumber = number.longValue();
        final double doubleValue = number.doubleValue();
        if (Double.compare((double) longNumber, doubleValue) == 0) {
            sb.append(longNumber);
        } else {
            sb.append(doubleValue);
        }
    }
}

The array paths carried the same defect, so a single non-finite element corrupted the whole array:

private static void formatDoubleArray(final StringBuilder sb, final double[] items) {
    sb.append(LBRACE);
    for (int itemIndex = 0; itemIndex < items.length; itemIndex++) {
        if (itemIndex > 0) {
            sb.append(COMMA);
        }
        final double item = items[itemIndex];
        sb.append(item);
    }
    sb.append(RBRACE);
}

formatFloatArray used the identical unguarded append for float[] values, and the fallback branch of formatNumber reached the same append for any other Number subclass whose doubleValue() is non-finite. There is no sanitization of map values upstream of the formatter, so nothing else in the path rejects or quotes the token.

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.5 and later, and in 2.26.1 for the 2.26 line.
  • Where upgrading is not immediately possible, keep untrusted floating-point values out of logged MapMessage instances (coerce them to strings or reject non-finite values at the application boundary), or emit log events through a layout that does not depend on MapMessage.asJson().
  • Leverage a commercial support partner like HeroDevs for post-EOL security support.

Credits

  • Himanshu Anand (finder)
Vulnerability Details
Severity
Level
CVSS Assessment
Low
>=0 <4
Medium
>=4 <6
High
>=6 <8
Critical
>=8 <10
Medium
ID
CVE-2026-49844
PROJECT Affected
Apache Log4j 2
Versions Affected
>=2.13.1 <=2.25.4, 2.26.0
NES Versions Affected
Published date
July 10, 2026
≈ Fix date
August 17, 2026
Category
Denial of Service
Content Spoofing
Vex Document
Download VEXHow do I use it?
Sign up for the latest vulnerability alerts fixed in
NES for Apache Log4j
Rss feed icon
Subscribe via RSS
or

By submitting the form I acknowledge receipt of our Privacy Policy.

Thanks for signing up for our Newsletter! We look forward to connecting with you.
Oops! Something went wrong while submitting the form.