7.5high
Improper Handling of Exceptional Conditions in Newtonsoft.Json
- Severity
- 7.5high CVSS:3.1 by CISA-ADP
- Exploit likelihood
- 2.47% (higher than 85% of CVEs)
- Published
- Last changed
- Assigned by
- VulnCheck
- Also known as
- GHSA-5crp-9r3c-p9vr
Description
Newtonsoft.Json before version 13.0.1 is affected by a mishandling of exceptional conditions vulnerability. Crafted data that is passed to the JsonConvert.DeserializeObject method may trigger a StackOverflow exception resulting in denial of service. Depending on the usage of the library, an unauthenticated and remote attacker may be able to cause the denial of service condition.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| Newtonsoft.Json | before 13.0.1 | CVE List |
| Newtonsoft.Json (NuGet) | before 13.0.1 | GitHub Advisory Database |
| newtonsoft json.net | before 13.0.1 | NVD |
All scores
| CISA-ADP | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
| GitHub | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
| NVD | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
Classification
SSVC (CISA-ADP): exploitation poc, automatable yes, technical impact partial.
What each source says
CVE List
Newtonsoft.Json before version 13.0.1 is affected by a mishandling of exceptional conditions vulnerability. Crafted data that is passed to the JsonConvert.DeserializeObject method may trigger a StackOverflow exception resulting in denial of service. Depending on the usage of the library, an unauthenticated and remote attacker may be able to cause the denial of service condition.
GitHub Advisory Database
Newtonsoft.Json prior to version 13.0.1 is vulnerable to Insecure Defaults due to improper handling of expressions with high nesting level that lead to StackOverFlow exception or high CPU and RAM usage. Exploiting this vulnerability results in Denial Of Service (DoS).
The serialization and deserialization path have different properties regarding the issue.
Deserializing methods (like JsonConvert.DeserializeObject) will process the input that results in burning the CPU, allocating memory, and consuming a thread of execution. Quite high nesting level (>10kk, or 9.5MB of {a:{a:{... input) is needed to achieve the latency over 10 seconds, depending on the hardware.
Serializing methods (like JsonConvert.Serialize or JObject.ToString) will throw StackOverFlow exception with the nesting level of around 20k.
To mitigate the issue one either need to update Newtonsoft.Json to 13.0.1 or set MaxDepth parameter in the JsonSerializerSettings. This can be done globally with the following statement. After that the parsing of the nested input will fail fast with Newtonsoft.Json.JsonReaderException:
JsonConvert.DefaultSettings = () => new JsonSerializerSettings { MaxDepth = 128 };
Repro code:
//Create a string representation of an highly nested object (JSON serialized)
int nRep = 25000;
string json = string.Concat(Enumerable.Repeat("{a:", nRep)) + "1" +
string.Concat(Enumerable.Repeat("}", nRep));
//Parse this object (leads to high CPU/RAM consumption)
var parsedJson = JsonConvert.DeserializeObject(json);
// Methods below all throw stack overflow with nRep around 20k and higher
// string a = parsedJson.ToString();
// string b = JsonConvert.SerializeObject(parsedJson);
Additional affected product and version information
The original statement about the problem only affecting IIS applications is misleading. Any application is affected, however the IIS has a behavior that stops restarting the instance after some time resulting in a harder-to-fix DoS.**
NVD (es)
Newtonsoft.Json anterior a la versión 13.0.1 se ve afectado por una vulnerabilidad de manejo incorrecto de condiciones excepcionales. Los datos elaborados que se pasan al método JsonConvert.DeserializeObject pueden desencadenar una excepción de StackOverflow que provoque una denegación de servicio. Dependiendo del uso de la librería, un atacante remoto y no autenticado puede provocar la condición de denegación de servicio.
References
| https://github.com/JamesNK/Newtonsoft.Json/issues/2457 | exploit, issue-tracking, third-party-advisory, web | |
| https://github.com/JamesNK/Newtonsoft.Json/pull/2462 | issue-tracking, patch, related, web | |
| https://github.com/JamesNK/Newtonsoft.Json/commit/7e77bbe1beccceac4fc7b174b53abfefac278b66 | patch, related, web | |
| https://alephsecurity.com/2018/10/22/StackOverflowException/ | exploit, related | |
| https://alephsecurity.com/vulns/aleph-2018004 | exploit, related, web | |
| https://security.snyk.io/vuln/SNYK-DOTNET-NEWTONSOFTJSON-2774678 | exploit, related, third-party-advisory, web | |
| https://github.com/advisories/GHSA-5crp-9r3c-p9vr | third-party-advisory, vendor-advisory | |
| https://vulncheck.com/advisories/vc-advisory-GHSA-5crp-9r3c-p9vr | third-party-advisory | |
| https://alephsecurity.com/2018/10/22/StackOverflowException | web | |
| https://github.com/JamesNK/Newtonsoft.Json | package | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2024-21907 changed 2026-11-08 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-5crp-9r3c-p9vr changed 2026-07-08 | CC-BY-4.0 |
| NVD | CVE-2024-21907 changed 2026-07-14 | Public domain |