CVE-2026-40021: Apache Log4net Silent Log Event Loss Vulnerability

MODERATE
Advisory Identifier: GHSA-4f7c-pmjv-c25w
CVSS 5.3
CWE-116
Published
Advisory Summary

CVE-2026-40021 is a MODERATE (CVSS 5.3) silent log event loss vulnerability (CWE-116: Improper Encoding or Escaping of Output) affecting Apache Log4net libraries in the NuGet ecosystem. The issue involves silent log event loss in xmllayout and xmllayoutschemalog4j due to unescaped xml 1.0 forbidden characters. Remediation is available by upgrading affected packages to version 3.3.0.

CVE-2026-40021 at a Glance

CVE Identifier CVE-2026-40021
GHSA Identifier GHSA-4f7c-pmjv-c25w
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-116: Improper Encoding or Escaping of Output
Affected Product Apache Log4net
Package Ecosystem NuGet
Published Date
Last Updated

Security Impact

CVSS: 5.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2026-40021

To remediate this vulnerability, upgrade all affected Apache Log4net dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

log4net fixed: 3.3.0
Upgrade log4net to 3.3.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for log4net

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-40021, inspect your project dependencies for Apache Log4net:

inspect dependencies for log4net

Analyze the terminal output to locate any version of Apache Log4net in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.3.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-116: Improper Encoding or Escaping of Output, where the product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. as a result, the intended structure of the message is not preserved. In Apache Log4net, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

Apache Log4net's XmlLayout https://logging.apache.org/log4net/manual/configuration/layouts.html#layout-list and XmlLayoutSchemaLog4J https://logging.apache.org/log4net/manual/configuration/layouts.html#layout-list , in versions before 3.3.0, fail to sanitize characters forbidden by the XML 1.0 specification https://www.w3.org/TR/xml/#charsets in MDC property keys and values, as well as the identity field that may carry attacker-influenced data. This causes an exception during serialization and the silent loss of the affected log event. An attacker who can influence any of these fields can exploit this to suppress individual log records, impairing audit trails and detection of malicious activity. Users are advised to upgrade to Apache Log4net 3.3.0, which fixes this issue.

CVE-2026-40021 Affected Apache Log4net Versions

1 component(s)
Fixed Versions:
3.3.0
Product / Package Ecosystem Affected Versions Fixed Version
log4net
NuGet
< 3.3.0
3.3.0

References

Frequently Asked Questions

What is CVE-2026-40021?
CVE-2026-40021 is a security vulnerability in Apache Log4net involving Silent log event loss in XmlLayout and XmlLayoutSchemaLog4J due to unescaped XML 1.0 forbidden characters under CWE-116: Improper Encoding or Escaping of Output.
Which Apache Log4net versions are affected?
Affected versions include releases prior to 3.3.0 across affected packages: log4net.
What version fixes CVE-2026-40021?
Upgrading to 3.3.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is log4net affected?
Yes, log4net is affected in releases prior to 3.3.0. Upgrade your dependency to 3.3.0 or later.
What is the CVSS score of CVE-2026-40021?
CVE-2026-40021 has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N.
What CWE is associated with CVE-2026-40021?
CVE-2026-40021 is classified under CWE-116: Improper Encoding or Escaping of Output (The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved.).
How can I check NuGet dependencies for CVE-2026-40021?
Run the dependency tree command: 'inspect dependencies for log4net'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-4f7c-pmjv-c25w",
  "modified" : "2026-04-27T16:18:56Z",
  "published" : "2026-04-10T18:31:18Z",
  "aliases" : [ "CVE-2026-40021" ],
  "summary" : "Apache Log4net: Silent log event loss in XmlLayout and XmlLayoutSchemaLog4J due to unescaped XML 1.0 forbidden characters",
  "details" : "Apache Log4net's  XmlLayout https://logging.apache.org/log4net/manual/configuration/layouts.html#layout-list  and  XmlLayoutSchemaLog4J https://logging.apache.org/log4net/manual/configuration/layouts.html#layout-list , in versions before 3.3.0, fail to sanitize characters forbidden by the  XML 1.0 specification https://www.w3.org/TR/xml/#charsets  in MDC property keys and values, as well as the identity field that may carry attacker-influenced data. This causes an exception during serialization and the silent loss of the affected log event.\n\nAn attacker who can influence any of these fields can exploit this to suppress individual log records, impairing audit trails and detection of malicious activity.\n\nUsers are advised to upgrade to Apache Log4net 3.3.0, which fixes this issue.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:H/AT:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:N/SI:L/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "log4net"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.3.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-40021"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/apache/logging-log4net/pull/280"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/apache/logging-log4net"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread/q8otftjswhk69n3kxslqg7cobr0x4st7"
  }, {
    "type" : "WEB",
    "url" : "https://logging.apache.org/cyclonedx/vdr.xml"
  }, {
    "type" : "WEB",
    "url" : "https://logging.apache.org/log4net/manual/configuration/layouts.html"
  }, {
    "type" : "WEB",
    "url" : "https://logging.apache.org/security.html#CVE-2026-40021"
  }, {
    "type" : "WEB",
    "url" : "http://www.openwall.com/lists/oss-security/2026/04/10/11"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-116" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-04-14T01:02:41Z",
    "nvd_published_at" : "2026-04-10T16:16:32Z"
  }
}