CVE-2024-21907: Improper Handling of Exceptional Conditions in Newtonsoft.Json

Published Jun 22, 2022
·
Updated

CVE-2024-21907 addresses a mishandling of exceptional conditions vulnerability in Newtonsoft.Json before version 13.0.1. 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. The documented SQL Server updates incorporate updates in Newtonsoft.Json which address this vulnerability. Please see CVE-2024-21907 for more information.

Other sources

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.

MITRE

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.

VulnCheck: CVE-2024-21907 Improper Handling of Exceptional Conditions in Newtonsoft.Json

Microsoft

Affected Software

8 affected componentsFixes available
nuget/Newtonsoft.Json<13.0.1
13.0.1
Newtonsoft Json.net<13.0.1
Microsoft SQL Server 2017 (CU 31)
Microsoft SQL Server 2016 Azure Connect Feature Pack
Microsoft SQL Server 2016
Microsoft SQL Server 2019
Microsoft SQL Server 2017
Microsoft SQL Server 2019 (CU 32)

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade nuget/Newtonsoft.Json to a version that resolves this vulnerability.

    Fixed in 13.0.1
  2. Upgrade

    Upgrade Newtonsoft.Json to a version that resolves this vulnerability.

    Fixed in 13.0.1Patch CVE-2024-21907
  3. Configuration

    Set JsonConvert.DefaultSettings to return new JsonSerializerSettings { MaxDepth = 128 } to limit nesting depth and mitigate CVE-2024-21907.

    Newtonsoft.Json JsonSerializerSettings.MaxDepth = 128

Event History

Jun 22, 2022
Advisory Published
03:08 PM
Jan 3, 2024
CVE Published
via MITRE·03:23 PM
Data Sourced
via MITRE·03:23 PM
DescriptionWeakness
Data Sourced
via NVD·04:15 PM
RemedyDescriptionSeverityWeaknessAffected Software
Dec 10, 2024
News Published
08:48 PM
Jul 8, 2025
News Published
11:01 PM
Sep 9, 2025
Data Sourced
via Microsoft·07:00 AM
DescriptionSeverityWeaknessAffected Software
Updated
via Microsoft·07:00 AM
Affected Software
Updated
via Microsoft·07:00 AM
Description
Sep 10, 2025
News Published
via The Register·03:31 AM
News Published
via The Register·03:36 AM
Sep 11, 2025
News Published
via ZDNet·06:35 PM
News Published
via ZDNet·06:53 PM
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2024-21907?

CVE-2024-21907 has a severity rating indicating it can lead to denial of service via a StackOverflow exception.

2

How do I fix CVE-2024-21907?

To resolve CVE-2024-21907, upgrade to Newtonsoft.Json version 13.0.1 or later.

3

What is the impact of CVE-2024-21907?

The impact of CVE-2024-21907 includes possible denial of service due to mishandling of exceptional conditions.

4

Which versions of Newtonsoft.Json are affected by CVE-2024-21907?

CVE-2024-21907 affects all versions of Newtonsoft.Json prior to 13.0.1.

5

Is there a workaround for CVE-2024-21907?

There is no known workaround for CVE-2024-21907 other than updating to the patched version.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203