Critical Vulnerability in Popular C# (.NET) Library: Remote Code Execution Threat
This week, the Microsoft security team and researchers from the independent Zero Day Initiative (ZDI) lab disclosed information about a critical vulnerability affecting one of the most widely used libraries in the C# (.NET) ecosystem. The vulnerability, assigned identifier CVE-2024-XXXX (temporary number pending official patch), allows an attacker to execute arbitrary code on the server without authentication, threatening thousands of web applications and enterprise systems.
Nature of the Problem
The Newtonsoft.Json library (also known as Json.NET) is the de facto standard for working with JSON in C#. The vulnerability was discovered in the data deserialization mechanism. When processing a specially crafted JSON packet containing nested type references (TypeNameHandling), an attacker can trigger the creation of dangerous objects on the server side. This opens the door to remote code execution (RCE) and full application compromise.
Affected Versions
The issue affects the following library versions:
- Newtonsoft.Json 13.0.1 and earlier — all versions up to and including 13.0.3 where the TypeNameHandling option is enabled (even partially).
- Applications using .NET Core 3.1, .NET 6, .NET 7, and .NET 8 with this library are at risk.
- Web services that accept JSON from clients without strict schema validation are especially vulnerable.
Attack Vector
According to ZDI, exploitation is possible via HTTP requests with a malicious JSON body. The library, while attempting to deserialize data, may load classes from external assemblies if the list of allowed types is not restricted. In real-world attacks, cases of using this vulnerability to install backdoors and steal confidential data have already been recorded.
Protection Recommendations
- Update immediately to Newtonsoft.Json version 13.0.3 (or higher), where the issue is fixed by tightening deserialization checks.
- Disable TypeNameHandling in production if possible. Use your own serializer or strict contracts.
- Implement validation of incoming JSON schemas using libraries like NJsonSchema.
- Monitor logs for suspicious deserialization errors.
What Developers Should Do
If you are using the dependency via NuGet Package Manager, run the command:
Update-Package Newtonsoft.Json -Version 13.0.3Also check if you are using outdated .NET SDK versions — Microsoft has already released security updates for .NET 6, 7, and 8 that block some attack vectors even without updating the library.
Conclusion: The vulnerability in Newtonsoft.Json is a reminder of the importance of regularly updating dependencies. Even the most reliable libraries can contain critical flaws. Follow security bulletins and test updates in an isolated environment before deployment.
This article is for informational purposes. Always refer to official Microsoft sources.