Apr 17, 2026·6 min read·11 visits
Unbounded recursion in .NET's XML cryptography processing allows remote attackers to trigger a stack overflow and subsequent Denial of Service by supplying deeply nested XML elements.
Microsoft .NET and Visual Studio contain a stack-based buffer overflow vulnerability within the System.Security.Cryptography.Xml library. The flaw occurs due to unbounded recursion when processing deeply nested XML-based cryptographic structures, allowing unauthenticated attackers to cause a Denial of Service (DoS) via process exhaustion.
CVE-2026-32203 is a critical Denial of Service (DoS) vulnerability impacting the System.Security.Cryptography.Xml library in Microsoft .NET and Visual Studio. The vulnerability manifests as a Stack-based Buffer Overflow (CWE-121) triggered by Improper Input Validation (CWE-20). The affected component handles cryptographic operations on XML structures, specifically focusing on canonicalization (C14N) and the parsing of encrypted elements.
The attack surface exposes any .NET application that processes untrusted XML payloads containing cryptographic structures. Public-facing web services, API endpoints parsing SOAP messages, and applications validating XML signatures are at the highest risk. An unauthenticated remote attacker exploits this vulnerability by sending a maliciously crafted XML document to the targeted service.
The core issue resides in the recursive nature of the XML parsing logic. The library recursively evaluates child nodes without enforcing a maximum depth threshold. This architectural oversight allows an attacker to dictate the execution flow's call stack depth, ultimately exhausting the thread's allocated stack memory and terminating the host process.
The root cause of CVE-2026-32203 lies in the absence of recursion depth limits within the .NET runtime's handling of specific XML cryptography namespaces. When an application attempts to decrypt or verify a signature containing <EncryptedData> or <EncryptedKey> elements, the System.Security.Cryptography.Xml library invokes the LoadXml method. This method acts as an entry point for parsing the internal structure of the encrypted element.
During processing, the LoadXml method recursively calls itself or related dispatcher methods to evaluate child nodes such as KeyInfo, EncryptionMethod, and CipherData. If an XML payload contains a continuous chain of nested <EncryptedData> elements, the recursion continues unimpeded. Each recursive call consumes additional stack frames. The standard thread stack size in .NET applications is finite, typically bounded at 1.5MB to 8MB depending on the environment and architecture.
When the recursion depth exceeds the available thread stack, the operating system raises a stack overflow exception. Unlike standard managed exceptions in .NET, a StackOverflowException cannot be caught or handled by the application code under default configurations. The .NET runtime immediately terminates the process to prevent memory corruption, directly fulfilling the Denial of Service objective.
The logical flow of the vulnerability is mapped below:
An analysis of the patch implemented in the .NET runtime (Commit b234b9ae5980f21c499ae0702b098d9898ec786f) reveals the specific mechanisms introduced to restrict unbounded recursion. The remediation focuses on tracking the call stack depth and enforcing a hard limit during the evaluation of XML cryptography elements.
The fix introduces a thread-local variable to maintain the current depth context without introducing synchronization overhead. The developers added a [ThreadStatic] integer variable named t_depth to the CanonicalizationDispatcher, EncryptedData, and EncryptedKey classes. Each recursive entry point increments this counter and decrements it upon returning.
// Conceptual representation of the patched logic in LoadXml
[ThreadStatic]
private static int t_depth;
public void LoadXml(XmlElement value)
{
try
{
t_depth++;
if (t_depth > System.Security.Cryptography.Xml.DangerousMaxRecursionDepth)
{
throw new CryptographicException("The XML element has exceeded the maximum nesting depth allowed for decryption.");
}
// Original parsing logic for KeyInfo, EncryptionMethod, etc.
ParseChildNodes(value);
}
finally
{
t_depth--;
}
}The DangerousMaxRecursionDepth is controlled via an AppContext switch and defaults to a value of 64. If an attacker submits an XML structure nested deeper than 64 levels, the logic preemptively aborts the operation. It throws a standard CryptographicException rather than faulting the thread. The application can catch this exception, preserving process availability.
Exploiting CVE-2026-32203 requires minimal prerequisites. The attacker only needs the ability to submit XML data to a .NET application configured to process XML cryptography features. The vulnerability does not require authentication, specific user interactions, or complex memory manipulation techniques typically associated with buffer overflows.
The attack methodology involves generating a syntactically valid XML document containing deeply nested tags associated with the http://www.w3.org/2001/04/xmlenc# namespace. The payload structure typically consists of thousands of nested <EncryptedData> elements. The attacker submits this payload via standard attack vectors, such as HTTP POST requests targeting SOAP APIs, or file upload functionalities accepting signed XML documents.
Upon receiving the request, the victim service begins parsing the document. Because the XML parser consumes the data synchronously, the parsing thread enters the recursive loop immediately. The stack limits are exhausted within milliseconds, causing an uncatchable exception. The process terminates abruptly, dropping all active connections and terminating service availability until the process restarts.
The direct impact of CVE-2026-32203 is a complete loss of availability for the targeted service. The StackOverflowException terminates the hosting process, which halts all current operations. For applications handling high transaction volumes or managing persistent state, this sudden termination induces significant disruption and potential data inconsistency for in-flight transactions.
While the vulnerability is categorized as a Stack-based Buffer Overflow (CWE-121), the runtime environment mitigates the potential for Remote Code Execution (RCE). The .NET framework handles stack overflow conditions by forcefully terminating the process before the attacker can overwrite return addresses or hijack the execution flow. Therefore, the confidentiality and integrity of the system remain intact.
The vulnerability carries a CVSS 3.1 Base Score of 7.5, reflecting its high availability impact, lack of required privileges, and low attack complexity. The Exploit Prediction Scoring System (EPSS) score remains low at 0.00139 (34.04th percentile), indicating a lower statistical likelihood of imminent active exploitation compared to higher-profile remote code execution flaws. The issue is currently absent from the CISA Known Exploited Vulnerabilities (KEV) catalog.
The primary remediation strategy requires upgrading the affected .NET framework and Visual Studio installations to their respective patched versions. Microsoft resolved the vulnerability in .NET 10.0.6, .NET 9.0.15, and .NET 8.0.26. Visual Studio users must upgrade to version 17.12.19 or 17.14.30. Organizations should prioritize updating internet-facing applications that parse external XML inputs.
For environments unable to deploy immediate framework updates, administrators can employ external mitigation controls. Web Application Firewalls (WAF) can detect and block malicious payloads by inspecting the depth of XML elements. Security teams should configure WAF rules to reject XML inputs containing unusually deep nesting of http://www.w3.org/2001/04/xmlenc#EncryptedData or EncryptedKey elements. Setting a strict size limit on incoming XML requests also reduces the likelihood of exploitation.
Post-patching, administrators retain the ability to modify the recursion limits if necessary. The patch introduces the System.Security.Cryptography.Xml.DangerousMaxRecursionDepth AppContext switch. While the default limit of 64 is sufficient for nearly all legitimate cryptographic operations, applications requiring deeper nesting can adjust this threshold via application configuration files. Modifying this value is strictly discouraged unless dictated by explicit business requirements.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H/E:U/RL:O/RC:C| Product | Affected Versions | Fixed Version |
|---|---|---|
Microsoft .NET 10.0 Microsoft | <= 10.0.5 | 10.0.6 |
Microsoft .NET 9.0 Microsoft | <= 9.0.14 | 9.0.15 |
Microsoft .NET 8.0 Microsoft | <= 8.0.25 | 8.0.26 |
Microsoft Visual Studio 2022 v17.12 Microsoft | <= 17.12.18 | 17.12.19 |
Microsoft Visual Studio 2022 v17.14 Microsoft | <= 17.14.29 | 17.14.30 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-121 / CWE-20 |
| Attack Vector | Network |
| CVSS 3.1 Base | 7.5 |
| EPSS Score | 0.13% |
| Impact | Denial of Service (DoS) |
| Exploit Status | None / Unproven |
| CISA KEV | Not Listed |
| Patch Status | Available |
The vulnerability involves improper validation of recursion depth in XML element processing, leading to stack exhaustion.