CVE-2026-40021: Apache Log4net Silent Log Event Loss Vulnerability
MODERATECVE-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
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).
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.
Upgrade log4net to 3.3.0
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
CVE-2026-40021 Affected Apache Log4net Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
log4net
|
NuGet |
< 3.3.0
|
3.3.0
|
References
Frequently Asked Questions
What is CVE-2026-40021?
Which Apache Log4net versions are affected?
What version fixes CVE-2026-40021?
Is log4net affected?
What is the CVSS score of CVE-2026-40021?
What CWE is associated with CVE-2026-40021?
How can I check NuGet dependencies for CVE-2026-40021?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"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"
}
}