CVE-2022-31117: Potential double free of buffer during string decoding in ujson

ujson Updated 02 Oct 2025

Summary

05/07/2022
Yes i
Moderate
5.9

CVE-2022-31117: Potential double free of buffer during string decoding. Affects ujson versions < 5.4.0. Fixed in 5.4.0. How to fix ↓

Also tracked for

The same CVE-2022-31117 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

ujson is a Python library that provides ultra-fast JSON encoding and decoding. It is commonly used to serialize and deserialize JSON data in Python applications. This vulnerability affects ujson versions prior to 5.4.0. The vulnerability arises when an error occurs during the reallocation of the buffer for string decoding, leading to a double free of the buffer. However, it is important to note that this double free cannot be triggered from Python due to the internal decoder used by UltraJSON.

Vulnerability Detail

The vulnerability in ujson can result in a potential double free of the buffer during string decoding. This occurs when an error occurs while reallocating the buffer, causing it to be freed twice. Although this vulnerability cannot be triggered from Python, it poses a risk to applications that use ujson for JSON encoding and decoding. The impact of this vulnerability can vary depending on the context in which ujson is used, but it could potentially lead to memory corruption or crashes.

How To Fix

Latest published version: 6.0.0 as of 23 Oct 2026

pip install --upgrade "ujson==6.0.0"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

5.4.0

This is the first release that contains the fix.

pip install --upgrade "ujson==5.4.0"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

There is no known workaround for this vulnerability. Upgrading to UltraJSON 5.4.0 or later is the recommended solution.

Conclusion

The potential double free vulnerability in ujson can be mitigated by upgrading to UltraJSON 5.4.0 or later. This vulnerability, although not exploitable from Python, could lead to memory corruption or crashes in applications that use ujson for JSON encoding and decoding. It is recommended to promptly update ujson to the latest version to ensure the security and stability of your Python applications. For further support on vulnerability remediation, you can reach out to DevNack.com.

See every vulnerability recorded for ujson →

Share this vulnerability

FAQ

No, this vulnerability cannot be triggered from Python due to the internal decoder used by UltraJSON.

The impact of this vulnerability can vary depending on the context in which ujson is used. It could potentially lead to memory corruption or crashes.

No, only versions prior to 5.4.0 are affected. Users should upgrade to UltraJSON 5.4.0 or later to mitigate the vulnerability.

No, there is no known workaround for this vulnerability. Upgrading to UltraJSON 5.4.0 or later is the recommended solution.

For more information, you can open an issue in the UltraJSON GitHub repository: http://github.com/ultrajson/ultrajson/issues

Related vulnerabilities

Recent vulnerabilities recorded for ujson.

How To Fix

Latest published version: 6.0.0 as of 23 Oct 2026

pip install --upgrade "ujson==6.0.0"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

5.4.0

This is the first release that contains the fix.

pip install --upgrade "ujson==5.4.0"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback