Improper Handling of Exceptional Conditions in Newtonsoft.Json
CVE-2024-21907 (GitHub advisory GHSA-5crp-9r3c-p9vr) is a high-severity vulnerability with a CVSS 3.1 base score of 7.5, classed as Improper Handling of Exceptional Conditions (CWE-755), in Newtonsoft.Json (NuGet). Affected versions: < 13.0.1. It is fixed in 13.0.1.
Published 22 Jun 2022Updated 14 Jul 2026
- CVE ID
- CVE-2024-21907
- GHSA ID
- GHSA-5crp-9r3c-p9vr
- EPSS
- 32.9%higher than 98% of CVEs
- Weakness (CWE)
- CWE-755Improper Handling of Exceptional Conditions
- KEV status
- Not in KEV
- Published
- 22 Jun 2022
- Updated
- 14 Jul 2026
- Ecosystem
- NuGet
- Assigned by (CNA)
- VulnCheck
Summary
Source: OSV (GitHub advisory)
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.**
Technical details
Source: GitHub Advisory Database
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:HHigh7.5Base score from GitHub Advisory Database
- Attack Vector AV
- Network
- Attack Complexity AC
- Low
- Privileges Required PR
- None
- User Interaction UI
- None
- Scope S
- Unchanged
- Confidentiality C
- None
- Integrity I
- None
- Availability A
- High
CISA SSVC decision points
- Exploitation
- poc
- Proof-of-concept code is public
- Automatable
- yes
- Attackers can automate this at scale
- Technical impact
- partial
- Limited control of the affected system
CISA Coordinator assessment (SSVC 2.0.3) via CVE.org.
Affected packages
Source: OSV (GitHub advisory)
- Newtonsoft.JsonNuGet
pkg:nuget/Newtonsoft.Json- Affected versions
- < 13.0.1
- Fixed in
- 13.0.1
Show 74 listed versions
- 10.0.1
- 10.0.1-beta1
- 10.0.2
- 10.0.3
- 11.0.1
- 11.0.1-beta1
- 11.0.1-beta2
- 11.0.1-beta3
- 11.0.2
- 12.0.1
- 12.0.1-beta1
- 12.0.1-beta2
| Package | Affected versions | Fixed in |
|---|---|---|
Newtonsoft.Json NuGet pkg:nuget/Newtonsoft.Json |
Show 74 listed versions
|
|
Fix
Source: OSV (GitHub advisory)
Fix available
Upgrade to 13.0.1 or later.
Patch commits
Change JsonReader and JsonSerializer default max depth to 128 (#2462)
+48 −3 across 4 files
- Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs+41 −0
- Src/Newtonsoft.Json/JsonReader.cs+3 −0
- Src/Newtonsoft.Json/JsonSerializer.cs+1 −1
- Src/Newtonsoft.Json/JsonSerializerSettings.cs+3 −2
Release commits
The commits each fixed release tag points at. They usually bump the version rather than contain the fix itself.
Vulnerability intelligence
Root cause analysis
Vulnerable functions
References
Fixes 2
Advisories 4
Reports and issues 1
Package 1
Credits
Questions about CVE-2024-21907
- What is the GHSA ID for CVE-2024-21907?
- GitHub tracks CVE-2024-21907 as GHSA-5crp-9r3c-p9vr.
- What is the CVSS score of CVE-2024-21907?
- CVE-2024-21907 has a CVSS 3.1 base score of 7.5 (High), vector CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
- Which versions are affected by CVE-2024-21907?
- Newtonsoft.Json (NuGet): < 13.0.1.
- How do I fix CVE-2024-21907?
- Upgrade to 13.0.1 or later. The fix is in commit 7e77bbe and pull request #2462.
- What is the Package URL (PURL) for CVE-2024-21907?
- The affected package's PURL is pkg:nuget/Newtonsoft.Json.
- Is CVE-2024-21907 exploited in the wild?
- CISA's Known Exploited Vulnerabilities catalog doesn't list CVE-2024-21907. That means no confirmed exploitation has been catalogued, not that it is safe to leave unpatched. CISA's SSVC assessment rates exploitation as "poc". EPSS estimates a 32.9% chance of exploitation in the next 30 days, higher than 98% of CVEs.
Data sources
Upstream records
- OSV (GitHub advisory)LoadedRaw JSON
- GitHub Advisory DatabaseLoadedRaw JSON
- OSV (CVE record)LoadedRaw JSON
- CVE.orgLoaded
- CISA KEV catalogLoaded
Fetched 6 days ago (8 Oct 2026, 12:33 UTC). Records refresh automatically after 24 hours.
Where each part of this page came from
- Title and description
- OSV (GitHub advisory)
- Severity score
- GitHub Advisory Database
- Weakness (CWE)
- GitHub Advisory Database
- Affected packages
- OSV (GitHub advisory)
- Fix
- OSV (GitHub advisory)
- References
- Computed by CVEminer
- SSVC
- CVE.org
- KEV status
- CISA KEV catalog
- EPSS
- GitHub Advisory Database
OSV and GitHub Advisory Database content is licensed CC BY 4.0. Values marked as computed or derived were calculated by CVEminer from the upstream data.