Skip to main content

CVE-2022-31117: CWE-415: Double Free in ultrajson ultrajson

Medium
VulnerabilityCVE-2022-31117cvecve-2022-31117cwe-415-double-free
Published: Tue Jul 05 2022 (07/05/2022, 17:30:13 UTC)
Source: CVE
Vendor/Project: ultrajson
Product: ultrajson

Description

UltraJSON is a fast JSON encoder and decoder written in pure C with bindings for Python 3.7+. In versions prior to 5.4.0 an error occurring while reallocating a buffer for string decoding can cause the buffer to get freed twice. Due to how UltraJSON uses the internal decoder, this double free is impossible to trigger from Python. This issue has been resolved in version 5.4.0 and all users should upgrade to UltraJSON 5.4.0. There are no known workarounds for this issue.

AI-Powered Analysis

AILast updated: 06/23/2025, 03:04:55 UTC

Technical Analysis

CVE-2022-31117 is a medium-severity vulnerability classified as CWE-415 (Double Free) found in UltraJSON (ujson), a high-performance JSON encoder and decoder implemented in pure C with Python bindings for versions 3.7 and above. The vulnerability affects UltraJSON versions prior to 5.4.0. Specifically, the issue arises during the reallocation of a buffer used for string decoding. If an error occurs during this reallocation, the buffer may be freed twice, leading to a double free condition. Double free vulnerabilities can cause undefined behavior including memory corruption, application crashes, or potentially arbitrary code execution depending on the context and memory layout. However, in this case, the internal design of UltraJSON's decoder prevents this double free from being triggered directly through Python bindings, limiting the exploitability from typical Python application usage. The vulnerability was publicly disclosed on July 5, 2022, and has been resolved in UltraJSON version 5.4.0. There are currently no known exploits in the wild, and no workarounds exist aside from upgrading to the patched version. The vulnerability does not have a CVSS score assigned but is considered medium severity based on the nature of the flaw and its limited exploitability vector. UltraJSON is commonly used in Python applications requiring fast JSON parsing and encoding, including web services, data processing pipelines, and other software components that handle JSON data at scale.

Potential Impact

For European organizations, the impact of CVE-2022-31117 is primarily related to the stability and security of applications that embed UltraJSON versions prior to 5.4.0. While the vulnerability does not appear exploitable directly from Python, applications that use UltraJSON in lower-level C extensions or in environments where the internal decoder is accessed differently could be at risk of memory corruption or denial of service through application crashes. This could disrupt critical services that rely on JSON data processing, such as financial transaction systems, healthcare data exchanges, or real-time analytics platforms. Although there are no known exploits currently, the presence of a double free vulnerability could be leveraged in targeted attacks to compromise system integrity or availability, especially in high-value environments. European organizations with software supply chains that include UltraJSON should be aware of the risk of indirect exploitation, particularly if custom or legacy components interface with UltraJSON at the C level. The impact on confidentiality is limited unless the vulnerability is chained with other exploits to achieve code execution. Integrity and availability impacts are more probable due to potential crashes or memory corruption. Given the widespread use of JSON in modern applications, the vulnerability could affect a broad range of sectors including finance, telecommunications, government services, and critical infrastructure within Europe.

Mitigation Recommendations

The primary and most effective mitigation is to upgrade all UltraJSON dependencies to version 5.4.0 or later, where the double free vulnerability has been fixed. Organizations should conduct a thorough inventory of software components and dependencies to identify any usage of UltraJSON versions prior to 5.4.0, including indirect dependencies pulled in by other Python packages or C extensions. For environments where immediate upgrading is not feasible, consider isolating or sandboxing applications that use vulnerable UltraJSON versions to limit potential impact from crashes or memory corruption. Additionally, implement runtime protections such as memory corruption mitigations (e.g., Address Space Layout Randomization (ASLR), Data Execution Prevention (DEP), and Control Flow Integrity (CFI)) to reduce the risk of exploitation. Security teams should monitor for unusual application crashes or behavior that could indicate attempts to trigger the vulnerability. Finally, ensure that software supply chain security practices are in place to prevent introduction of vulnerable UltraJSON versions in future deployments.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
GitHub_M
Date Reserved
2022-05-18T00:00:00.000Z
Cisa Enriched
true

Threat ID: 682d9844c4522896dcbf36e3

Added to database: 5/21/2025, 9:09:24 AM

Last enriched: 6/23/2025, 3:04:55 AM

Last updated: 8/13/2025, 8:11:18 PM

Views: 11

Actions

PRO

Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.

Please log in to the Console to use AI analysis features.

Need enhanced features?

Contact root@offseq.com for Pro access with improved analysis and higher rate limits.

Latest Threats