Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2026-105241 Overview
CVE-2026-105241 is an improper Unicode encoding handling vulnerability [CWE-176] in the SmtpPickupDirAppender component of Apache log4net. When the mail file writer encounters content it cannot encode, such as an unpaired UTF-16 surrogate, the write operation throws an exception. Every buffered event in the batch is discarded rather than only the offending event, and a truncated mail file can be left in the pickup directory. An attacker whose data reaches a log message can suppress records of other logged events, impacting log integrity. The flaw affects Apache log4net versions from 1.2.9 before 3.5.0, and only applications that configure SmtpPickupDirAppender are affected.
Critical Impact
Attackers who control any portion of a log message can inject unencodable Unicode content to purge entire batches of buffered log events, undermining audit trails and forensic investigations.
Affected Products
- Apache log4net 1.2.9 through versions before 3.5.0
- .NET applications configured with SmtpPickupDirAppender
- Environments relying on log4net batched email logging via pickup directories
Discovery Timeline
- 2026-10-06 - CVE-2026-105241 published to the National Vulnerability Database (NVD)
- 2026-10-07 - Public disclosure via the OpenWall OSS-Security Post
- 2026-10-07 - Last updated in NVD database
Technical Details for CVE-2026-105241
Vulnerability Analysis
The vulnerability resides in the SmtpPickupDirAppender class, which writes buffered logging events to a file in a configured pickup directory for later delivery by a mail service. The appender uses File.CreateText, which produces a StreamWriter with default UTF-8 encoding that throws on content it cannot represent, such as an unpaired UTF-16 surrogate character.
When the throw occurs mid-batch, the exception propagates up the appender's buffered flush path. The partially written file remains in the pickup directory and the entire buffer of pending events is abandoned without being persisted. This converts a per-event encoding error into a batch-wide loss of logging data.
Root Cause
The root cause is improper handling of unencodable Unicode input [CWE-176] inside the appender's write loop. The writer does not sanitize or escape characters that fall outside the target encoding before serialization. Any single malformed event terminates the write operation and discards the surrounding buffered events along with it.
Attack Vector
The attack vector is network-reachable in deployments where untrusted input flows into log messages, for example HTTP request fields, usernames, or user-submitted data that is logged by the application. By injecting an unpaired surrogate or other unencodable sequence, an attacker causes the batch flush to fail, suppressing legitimate log records written alongside the malicious entry.
+<?xml version="1.0" encoding="UTF-8"?>
+<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="https://logging.apache.org/xml/ns"
+ xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
+ type="fixed">
+ <issue id="315" link="https://github.com/apache/logging-log4net/pull/315"/>
+ <description format="asciidoc">
+ stop one logging event destroying a whole `SmtpPickupDirAppender` batch. `File.CreateText`
+ throws on content it cannot encode, such as an unpaired surrogate, which abandoned every buffered
+ event and left a truncated mail in the pickup directory for the service to send. Such content is
+ now written as a `\uXXXX` escape (audit da18b6fd-f011)
+ </description>
+</entry>
Source: Apache logging-log4net commit 4d2e10f
Detection Methods for CVE-2026-105241
Indicators of Compromise
- Truncated or zero-byte .eml files appearing in the configured SMTP pickup directory
- Gaps in log sequence identifiers or missing events during known high-traffic windows
- Application exceptions referencing EncoderFallbackException or StreamWriter writes in log4net stack traces
- Log messages containing suspicious high-surrogate code points (U+D800–U+DBFF) without matching low surrogates
Detection Strategies
- Inventory running .NET applications and inspect log4net configuration files for SmtpPickupDirAppender entries
- Monitor the log4net internal debug stream for ErrorHandler reports relating to pickup directory writes
- Correlate missing audit events with the presence of truncated mail files in the pickup directory
- Scan incoming logged fields for malformed UTF-16 sequences before they reach the appender
Monitoring Recommendations
- Alert on exceptions originating from the log4net.Appender.SmtpPickupDirAppender namespace
- Track pickup directory file counts and sizes; investigate anomalies in write patterns
- Centralize log4net diagnostics to a SIEM so that log suppression gaps become visible across hosts
How to Mitigate CVE-2026-105241
Immediate Actions Required
- Upgrade Apache log4net to version 3.5.0 or later, where the appender escapes unencodable characters as \uXXXX sequences
- Audit application configurations and identify every component using SmtpPickupDirAppender
- Review historical pickup directory contents for truncated mails that indicate prior exploitation attempts
- Validate and sanitize untrusted inputs before they are passed to log statements
Patch Information
The fix is delivered in Apache log4net 3.5.0. The patch modifies src/log4net/Appender/SmtpPickupDirAppender.cs to import System.Globalization, System.Text, and log4net.Appender.Internal, and rewrites event serialization so characters that the writer cannot encode are emitted as \uXXXX escapes instead of causing the stream to throw. Full details are available in the GitHub Pull Request #315 and the corresponding Apache Mailing List Thread.
Workarounds
- Replace SmtpPickupDirAppender with SmtpAppender or an alternative sink until patching is possible
- Configure an upstream filter in the log pipeline that strips or escapes unpaired surrogates before events reach the appender
- Reduce the appender's BufferSize to minimize the number of events lost per failed flush while a permanent fix is deployed
# Verify installed log4net version in a .NET project
dotnet list package | grep -i log4net
# Upgrade log4net to the patched release
dotnet add package log4net --version 3.5.0
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

