Buffer Overflow Vulnerability in UltraJSON (ujson) Package

ujson Updated 02 Oct 2025

Summary

01/01/2022
N/A
No i
Medium
5.5

CVE-2021-45958: UltraJSON (aka ujson) through 5.1.0 has a stack-based buffer overflow in Buffer_AppendIndentUnchecked (called from encode). Affects ujson versions < f6860f1f3d8d4e92b9be0e5815355a8976c6e75b. No fix is published. How to fix ↓

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

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

UltraJSON, commonly referred to as ujson, is a high-performance JSON encoding and decoding library for Python. It is designed to provide faster JSON processing compared to the standard library. The library is widely used in applications that require efficient data interchange. However, versions up to 5.1.0 are susceptible to a stack-based buffer overflow, which can lead to severe security issues.

Vulnerability Detail

The vulnerability, identified as CVE-2021-45958, arises from a stack-based buffer overflow in the Buffer_AppendIndentUnchecked function, which is invoked during the encoding process. This flaw allows an attacker to exploit the vulnerability by providing a large amount of indentation, potentially leading to arbitrary code execution or application crashes. The issue affects multiple versions of the ujson package, making it critical for users to address this vulnerability promptly.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Workaround

If upgrading is not immediately possible, a temporary workaround is to limit the amount of indentation used in JSON encoding. This can be achieved by modifying the encoding function to use a smaller value for indentation, thus avoiding the overflow condition.

Conclusion

The buffer overflow vulnerability in the UltraJSON (ujson) package poses significant risks to applications using affected versions. Users are strongly advised to upgrade to the latest version to mitigate potential security threats. Additionally, utilizing tools like Vulert can help monitor and manage open-source vulnerabilities effectively.

See every vulnerability recorded for ujson →

Share this vulnerability

FAQ

CVE-2021-45958 is a vulnerability in the UltraJSON (ujson) package that allows for a stack-based buffer overflow, potentially leading to arbitrary code execution.

All versions of ujson up to and including 5.1.0 are affected by this vulnerability.

You can use Vulert, which monitors open-source vulnerabilities in your software by analyzing the manifest file like package-lock.json. Visit Vulert Scanner to check your application without signup.

The CVSS score for CVE-2021-45958 is 5.5, indicating a moderate level of severity.

If an immediate upgrade is not feasible, consider limiting the indentation used in JSON encoding as a temporary workaround.

Related vulnerabilities

Recent vulnerabilities recorded for ujson.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. 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