Feed
7.5HIGH
CVE-2024-21907Improper Handling of Exceptional Conditions in Newtonsoft.Json
A high-severity vulnerability reachable over the network, needing no privileges and no user interaction. EPSS estimates a 2.5% chance of exploitation in the next 30 days. A fixed version is named.
- Exploited in the wild
- Not in KEV
- EPSS
- 2.5%
- percentile 85%
- Fix
- Named by a source
- CVE published 22 Jun 2022 (approx.)
Reference
None of the "Needs attention" rules apply right now.
EPSS 2.5% (+2) · Network attack vector (+10) · No privileges required (+5) · No user interaction (+5)
Immediate actions
- Newtonsoft.Json (NuGet): upgrade to 13.0.1 or later on your release line.
- Commit / pull request: https://github.com/JamesNK/Newtonsoft.Json/pull/2462
- Commit / pull request: https://github.com/JamesNK/Newtonsoft.Json/commit/7e77bbe1beccceac4fc7b174b53abfefac278b66
Who should check
Newtonsoft.Json (NuGet) pkg:nuget/newtonsoft.json
- Affected< 13.0.1Fixed in13.0.1OSV (GHSA-5crp-9r3c-p9vr)
Confirmed facts
- CVSS
- 7.5 HIGH (version 3.1)
- Score from
- GitHub Advisory Database (GHSA-5crp-9r3c-p9vr)
- Attack vector
- network
- Attack complexity
- low
- Privileges required
- none
- User interaction
- none
- Weakness
- CWE-755
Unknowns
- We show one CVSS score. Other sources may score this CVE differently.
Advisory text
Quoted from the source advisory (untrusted)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.**
Update history
No events recorded. Our history starts on 1 Jan 2025.
References
- otherhttps://github.com/JamesNK/Newtonsoft.Json/issues/2457
- commit / pull requesthttps://github.com/JamesNK/Newtonsoft.Json/pull/2462
- commit / pull requesthttps://github.com/JamesNK/Newtonsoft.Json/commit/7e77bbe1beccceac4fc7b174b53abfefac278b66
- otherhttps://alephsecurity.com/2018/10/22/StackOverflowException
- otherhttps://alephsecurity.com/vulns/aleph-2018004
- otherhttps://github.com/JamesNK/Newtonsoft.Json
- otherhttps://security.snyk.io/vuln/SNYK-DOTNET-NEWTONSOFTJSON-2774678
Sources
- EPSS by FIRST.org, Free to use, attribution requested. Scores generated by Empirical Security.
- GHSA-5crp-9r3c-p9vr (GitHub Advisory Database), CC BY 4.0.
- OSV.dev, Per database.
This page is our own presentation: records are shortened, normalised and merged. Licences
Last checked: kev 16 min ago · osv 15 min ago · nvd 76 min ago · epss 15 min ago · JSON · ask via MCP: explain_vulnerability
Also known as GHSA-5crp-9r3c-p9vr