CVE-2024-21907 — Vulnerability in Newtonsoft.Json — CVE Details
HIGH
Improper Handling of Exceptional Conditions in Newtonsoft.Json
Published June 22, 2022Updated July 8, 2026Source: osv
Summary
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.**
Advisory Timeline
- First published June 22, 2022 (1573 days ago).
- Last revised July 8, 2026 — 1477 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
NuGet
Update Newtonsoft.Json to 13.0.1 or laterdotnet add package Newtonsoft.Json --version 13.0.1
After upgrading, run your dependency scanner again to confirm the vulnerability is resolved.
Affected Packages (1)
Affects 1 ecosystem: nuget (1).
| Package | Ecosystem | Affected | Fixed In |
|---|---|---|---|
| Newtonsoft.Json | nuget | 10.0.1, 10.0.1-beta1, 10.0.2, 10.0.3 (+70 more) | 13.0.1 |
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
- CWE-755
CVSS Score Breakdown
What the CVSS (Common Vulnerability Scoring System) 7.5 score means for each attack dimension.
Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
High
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
References
- https://github.com/JamesNK/Newtonsoft.Json/issues/2457WEB
- https://github.com/JamesNK/Newtonsoft.Json/pull/2462WEB
- https://github.com/JamesNK/Newtonsoft.Json/commit/7e77bbe1beccceac4fc7b174b53abfefac278b66WEB
- https://alephsecurity.com/2018/10/22/StackOverflowExceptionWEB
- https://alephsecurity.com/vulns/aleph-2018004WEB
- https://github.com/JamesNK/Newtonsoft.JsonPACKAGE
- https://security.snyk.io/vuln/SNYK-DOTNET-NEWTONSOFTJSON-2774678WEB
Frequently Asked Questions
- What is CVE-2024-21907?
- Improper Handling of Exceptional Conditions in Newtonsoft.Json This vulnerability has been assigned a severity rating of HIGH (CVSS score: 7.5/10).
- How do I check if my project is affected by CVE-2024-21907?
- CVE-2024-21907 affects Newtonsoft.Json. Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2024-21907 and 200,000+ other known vulnerabilities.
Severity & Exploitability
CVSS Score
7.5
High exploitability or significant impact. Prioritize remediation within days.
Also Known As
GHSA-5crp-9r3c-p9vr
Related CVEs
- CVE-2026-106112HIGH
ImageSharp: ICC LUT16 output channel count can write beyond Vector4
- CVE-2026-106115HIGH
ImageSharp: TIFF CCITT T6 encoder writes beyond an undersized output buffer
Check if you're affected
Scan your dependencies to see if this vulnerability affects your projects.
Scan Your Dependencies