CVE-2024-21907
C# vulnerability analysis and mitigation

Overview

CVE-2024-21907 affects Newtonsoft.Json versions prior to 13.0.1, discovered and reported in 2018. This vulnerability is related to a mishandling of exceptional conditions where crafted data passed to the JsonConvert.DeserializeObject method may trigger a StackOverflow exception resulting in denial of service. The vulnerability received a CVSS v3.1 base score of 7.5 (High) (NVD, GitHub Advisory).

Technical details

The vulnerability stems from improper handling of expressions with high nesting levels in JSON processing. Deserializing methods will process deeply nested input resulting in high CPU and RAM usage, requiring approximately 10,000 levels of nesting (9.5MB of nested input) to achieve latency over 10 seconds. Serializing methods will throw a StackOverflow exception with a nesting level of around 20,000. The vulnerability is classified as CWE-755: Improper Handling of Exceptional Conditions (Snyk, Aleph Security).

Impact

The vulnerability can lead to Denial of Service (DoS) conditions. When exploited, it can cause process termination due to StackOverflow exceptions or resource exhaustion through high CPU and RAM consumption. This affects any application using the vulnerable versions of Newtonsoft.Json, with particular severity in IIS-hosted applications where the process termination behavior can lead to application pool shutdown (GitHub Advisory).

Mitigation and workarounds

The primary mitigation is to upgrade Newtonsoft.Json to version 13.0.1 or higher. Alternatively, users can set the MaxDepth parameter in JsonSerializerSettings to limit nested processing. This can be implemented globally using: JsonConvert.DefaultSettings = () => new JsonSerializerSettings { MaxDepth = 128 }. Version 13.0.1 sets this limit by default (GitHub Commit).

Additional resources


SourceThis report was generated using AI

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Get a personalized demo

Ready to see Wiz in action?

“Best User Experience I have ever seen, provides full visibility to cloud workloads.”
David EstlickCISO
“Wiz provides a single pane of glass to see what is going on in our cloud environments.”
Adam FletcherChief Security Officer
“We know that if Wiz identifies something as critical, it actually is.”
Greg PoniatowskiHead of Threat and Vulnerability Management