Improper output encoding in Apache Log4net
Key facts
- Attack vector
- Network
- Privileges required
- None
- User interaction
- None
- Attack complexity
- High
- Attack requirements
- None
- Impact type
- —
- Confidentiality · integrity · availability
- None · None · None
- Fix status
- Fixed
Attack profile from CVSS 4.0 · CNA. Fix status from CNA and GitHub.
Summary
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.
Why it matters now
SSVC decision points
CISA ADP · SSVC 2.0.3
- Exploitation
- None
- Automatable
- No
- Technical impact
- Partial
The decision (Track, Attend, Act) also depends on your mission and well-being impact; see CISA's SSVC guide.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| Apache | Apache Log4net | before 3.3.0 | 3.3.0 | Patch available | CNA |
| — | log4net (NuGet) | before 3.3.0 | 3.3.0 | Patch available | GHSA-4f7c-pmjv-c25w |
- Apache Log4net VendorApache Affected before 3.3.0 Fixed in 3.3.0 Patch available CNA
- log4net (NuGet) Vendor— Affected before 3.3.0 Fixed in 3.3.0 Patch available GHSA-4f7c-pmjv-c25w
Remediation
- Fix · CNA Apache Log4net (Apache Software Foundation) Fixed in 3.3.0
- Fix · GHSA-4f7c-pmjv-c25w log4net (NuGet) Fixed in 3.3.0 Advisory →
Vendor assessments
Timeline
- 2026-10-02 Threatist record created from CVE-2026-40021
- 2026-10-03 Alias added: GHSA-4f7c-pmjv-c25w
References
Advisory 5
More Apache Log4net vulnerabilities
- TI-2018-01190 XML external entity injection in Apache log4net CVSS 3.1CRITICAL 9.8
- TI-2026-68924 RemoteSyslogAppender in Apache log4net silently drops non-ASCII text CVSS 3.1MEDIUM 5.3
- TI-2026-68923 Apache log4net EventLogAppender silently discards oversize records CVSS 3.1MEDIUM 5.3
- TI-2026-68922 Log4net drops log events when ASP.NET request validation fails CVSS 3.1MEDIUM 5.3
- TI-2026-68921 Unencodable content drops a whole batch in Apache log4net appender CVSS 3.1MEDIUM 5.3
- TI-2026-68920 NUL character truncates log records in Apache log4net debug output CVSS 3.1MEDIUM 5.3
Sources
- CVE-2026-40021 · CVE Program
- CVE-2026-40021 · NVD
- FIRST EPSS
- GHSA-4f7c-pmjv-c25w · GitHub Advisory Database · CC BY 4.0
- CVE-2026-40021 · Red Hat security data · CC BY 4.0
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences