Every CVE Search/ Get API key

CVE-2021-45958

UltraJSON vulnerable to Out-of-bounds Write

5.5 MediumFix available

UltraJSON (aka ujson) through 5.1.0 has a stack-based buffer overflow in Buffer_AppendIndentUnchecked (called from encode). Exploitation can, for example, use a large amount of indentation.

Attack profile

How easy it is to exploit

Attack vector
Local
Complexity
Low
Privileges needed
None
User interaction
Required

What an attacker can affect

Confidentiality
None
Integrity
None
Availability
High

Exploit likelihood

1.67%Up 1.0 points since Jan 1, 2022
90%50%10%1%

What each source reports

NVD Score used 5.5

UltraJSON (aka ujson) through 5.1.0 has a stack-based buffer overflow in Buffer_AppendIndentUnchecked (called from encode). Exploitation can, for example, use a large amount of indentation.

Record
CVE-2021-45958
CVSS 3.1
5.5 MediumCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H
CVSS 2.0
4.3 MediumAV:N/AC:M/Au:N/C:N/I:N/A:P
Weakness
CWE-787
Updated
2026-11-02
CVE List No score

UltraJSON (aka ujson) through 5.1.0 has a stack-based buffer overflow in Buffer_AppendIndentUnchecked (called from encode). Exploitation can, for example, use a large amount of indentation.

Record
CVE-2021-45958
Updated
2026-11-02
EUVDEUVD-2022-0348 No score

UltraJSON (aka ujson) through 5.1.0 has a stack-based buffer overflow in Buffer_AppendIndentUnchecked (called from encode). Exploitation can, for example, use a large amount of indentation.

Record
EUVD-2022-0348
Updated
2026-11-03
GitHub AdvisoriesGHSA-fh56-85cw-5pq6 6.8

UltraJSON vulnerable to Out-of-bounds Write

UltraJSON (aka ujson) 1.34 through 5.1.0 has a stack-based buffer overflow in Buffer_AppendIndentUnchecked (called from encode).

Record
GHSA-fh56-85cw-5pq6
CVSS 4.0
6.8 MediumCVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N
CVSS 3.1
5.5 MediumCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H
Weakness
CWE-787
Updated
2026-11-02
OSVALPINE-CVE-2021-45958 5.5

UltraJSON (aka ujson) through 5.1.0 has a stack-based buffer overflow in Buffer_AppendIndentUnchecked (called from encode). Exploitation can, for example, use a large amount of indentation.

Record
ALPINE-CVE-2021-45958
CVSS 3.1
5.5 MediumCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H
Updated
2026-11-03
OSV 5.5

UltraJSON (aka ujson) through 5.1.0 has a stack-based buffer overflow in Buffer_AppendIndentUnchecked (called from encode). Exploitation can, for example, use a large amount of indentation.

Record
CVE-2021-45958
CVSS 3.1
5.5 MediumCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H
Updated
2026-11-02
Show 14 moreShow less
OSVDEBIAN-CVE-2021-45958 5.5

UltraJSON (aka ujson) through 5.1.0 has a stack-based buffer overflow in Buffer_AppendIndentUnchecked (called from encode). Exploitation can, for example, use a large amount of indentation.

Record
DEBIAN-CVE-2021-45958
CVSS 3.1
5.5 MediumCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H
Updated
2026-11-02
OSVGHSA-fh56-85cw-5pq6 6.8

UltraJSON vulnerable to Out-of-bounds Write

UltraJSON (aka ujson) 1.34 through 5.1.0 has a stack-based buffer overflow in Buffer_AppendIndentUnchecked (called from encode).

Record
GHSA-fh56-85cw-5pq6
CVSS 4.0
6.8 MediumCVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N
CVSS 3.1
5.5 MediumCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H
Weakness
CWE-787
Updated
2026-11-02
OSVOESA-2026-3606 7.5

python-ujson security update

UltraJSON

Security Fix(es):

UltraJSON (aka ujson) through 5.1.0 has a stack-based buffer overflow in Buffer_AppendIndentUnchecked (called from encode). Exploitation can, for example, use a large amount of indentation.(CVE-2021-45958)

UltraJSON is a fast JSON encoder and decoder written in pure C with bindings for Python 3.7+. Affected versions were found to improperly decode certain characters. JSON strings that contain escaped surrogate characters not part of a proper surrogate pair were decoded incorrectly. Besides corrupting strings, this allowed for potential key confusion and value overwriting in dictionaries. All users parsing JSON from untrusted sources are vulnerable. From version 5.4.0, UltraJSON decodes lone surrogates in the same way as the standard library's json module does, preserving them in the parsed output. Users are advised to upgrade. There are no known workarounds for this issue.(CVE-2022-31116)

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.(CVE-2022-31117)

UltraJSON is a fast JSON encoder and decoder written in pure C with bindings for Python 3.7+. Prior to 5.12.1, when ujson.dump() writes to a file-like object and the write operation raises an exception, the serialized JSON string object is not decremented, leaking memory. Each failed write operation leaks the full size of the serialized payload. This vulnerability is fixed in 5.12.1.(CVE-2026-44660)

UltraJSON is a fast JSON encoder and decoder written in pure C with bindings for Python 3.7+. Prior to 5.13.0, ujson.dumps() (or ujson.dump() or ujson.encode()) have a reject_bytes=False option. When set, they may accept malformed or truncated UTF-8 byte sequences, silently rewriting them into different Unicode characters instead of rejecting them. This leads to input validation bypass and data integrity issues. This vulnerability is fixed in 5.13.0.(CVE-2026-54911)

Record
OESA-2026-3606
CVSS 3.1
7.5 HighCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Updated
2026-11-02
OSVOESA-2026-3607 7.5

python-ujson security update

UltraJSON

Security Fix(es):

UltraJSON (aka ujson) through 5.1.0 has a stack-based buffer overflow in Buffer_AppendIndentUnchecked (called from encode). Exploitation can, for example, use a large amount of indentation.(CVE-2021-45958)

UltraJSON is a fast JSON encoder and decoder written in pure C with bindings for Python 3.7+. Versions 5.10 through 5.11.0 are vulnerable to buffer overflow or infinite loop through large indent handling. ujson.dumps() crashes the Python interpreter (segmentation fault) when the product of the indent parameter and the nested depth of the input exceeds INT32_MAX. It can also get stuck in an infinite loop if the indent is a large negative number. Both are caused by an integer overflow/underflow whilst calculating how much memory to reserve for indentation. And both can be used to achieve denial of service. To be vulnerable, a service must call ujson.dump()/ujson.dumps()/ujson.encode() whilst giving untrusted users control over the indent parameter and not restrict that indentation to reasonably small non-negative values. A service may also be vulnerable to the infinite loop if it uses a fixed negative indent. An underflow always occurs for any negative indent when the input data is at least one level nested but, for small negative indents, the underflow is usually accidentally rectified by another overflow. This issue has been fixed in version 5.12.0.(CVE-2026-32875)

UltraJSON is a fast JSON encoder and decoder written in pure C with bindings for Python 3.7+. Prior to 5.12.1, when ujson.dump() writes to a file-like object and the write operation raises an exception, the serialized JSON string object is not decremented, leaking memory. Each failed write operation leaks the full size of the serialized payload. This vulnerability is fixed in 5.12.1.(CVE-2026-44660)

UltraJSON is a fast JSON encoder and decoder written in pure C with bindings for Python 3.7+. Prior to 5.13.0, ujson.dumps() (or ujson.dump() or ujson.encode()) have a reject_bytes=False option. When set, they may accept malformed or truncated UTF-8 byte sequences, silently rewriting them into different Unicode characters instead of rejecting them. This leads to input validation bypass and data integrity issues. This vulnerability is fixed in 5.13.0.(CVE-2026-54911)

Record
OESA-2026-3607
CVSS 3.1
7.5 HighCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Updated
2026-11-02
OSVOESA-2026-3608 7.5

python-ujson security update

UltraJSON

Security Fix(es):

UltraJSON (aka ujson) through 5.1.0 has a stack-based buffer overflow in Buffer_AppendIndentUnchecked (called from encode). Exploitation can, for example, use a large amount of indentation.(CVE-2021-45958)

UltraJSON is a fast JSON encoder and decoder written in pure C with bindings for Python 3.7+. Versions 5.10 through 5.11.0 are vulnerable to buffer overflow or infinite loop through large indent handling. ujson.dumps() crashes the Python interpreter (segmentation fault) when the product of the indent parameter and the nested depth of the input exceeds INT32_MAX. It can also get stuck in an infinite loop if the indent is a large negative number. Both are caused by an integer overflow/underflow whilst calculating how much memory to reserve for indentation. And both can be used to achieve denial of service. To be vulnerable, a service must call ujson.dump()/ujson.dumps()/ujson.encode() whilst giving untrusted users control over the indent parameter and not restrict that indentation to reasonably small non-negative values. A service may also be vulnerable to the infinite loop if it uses a fixed negative indent. An underflow always occurs for any negative indent when the input data is at least one level nested but, for small negative indents, the underflow is usually accidentally rectified by another overflow. This issue has been fixed in version 5.12.0.(CVE-2026-32875)

UltraJSON is a fast JSON encoder and decoder written in pure C with bindings for Python 3.7+. Prior to 5.12.1, when ujson.dump() writes to a file-like object and the write operation raises an exception, the serialized JSON string object is not decremented, leaking memory. Each failed write operation leaks the full size of the serialized payload. This vulnerability is fixed in 5.12.1.(CVE-2026-44660)

UltraJSON is a fast JSON encoder and decoder written in pure C with bindings for Python 3.7+. Prior to 5.13.0, ujson.dumps() (or ujson.dump() or ujson.encode()) have a reject_bytes=False option. When set, they may accept malformed or truncated UTF-8 byte sequences, silently rewriting them into different Unicode characters instead of rejecting them. This leads to input validation bypass and data integrity issues. This vulnerability is fixed in 5.13.0.(CVE-2026-54911)

Record
OESA-2026-3608
CVSS 3.1
7.5 HighCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Updated
2026-11-02
OSVOESA-2026-3720 7.5

python-ujson security update

UltraJSON

Security Fix(es):

UltraJSON (aka ujson) through 5.1.0 has a stack-based buffer overflow in Buffer_AppendIndentUnchecked (called from encode). Exploitation can, for example, use a large amount of indentation.(CVE-2021-45958)

UltraJSON is a fast JSON encoder and decoder written in pure C with bindings for Python 3.7+. Versions 5.10 through 5.11.0 are vulnerable to buffer overflow or infinite loop through large indent handling. ujson.dumps() crashes the Python interpreter (segmentation fault) when the product of the indent parameter and the nested depth of the input exceeds INT32_MAX. It can also get stuck in an infinite loop if the indent is a large negative number. Both are caused by an integer overflow/underflow whilst calculating how much memory to reserve for indentation. And both can be used to achieve denial of service. To be vulnerable, a service must call ujson.dump()/ujson.dumps()/ujson.encode() whilst giving untrusted users control over the indent parameter and not restrict that indentation to reasonably small non-negative values. A service may also be vulnerable to the infinite loop if it uses a fixed negative indent. An underflow always occurs for any negative indent when the input data is at least one level nested but, for small negative indents, the underflow is usually accidentally rectified by another overflow. This issue has been fixed in version 5.12.0.(CVE-2026-32875)

UltraJSON is a fast JSON encoder and decoder written in pure C with bindings for Python 3.7+. Prior to 5.12.1, when ujson.dump() writes to a file-like object and the write operation raises an exception, the serialized JSON string object is not decremented, leaking memory. Each failed write operation leaks the full size of the serialized payload. This vulnerability is fixed in 5.12.1.(CVE-2026-44660)

UltraJSON is a fast JSON encoder and decoder written in pure C with bindings for Python 3.7+. Prior to 5.13.0, ujson.dumps() (or ujson.dump() or ujson.encode()) have a reject_bytes=False option. When set, they may accept malformed or truncated UTF-8 byte sequences, silently rewriting them into different Unicode characters instead of rejecting them. This leads to input validation bypass and data integrity issues. This vulnerability is fixed in 5.13.0.(CVE-2026-54911)

Record
OESA-2026-3720
CVSS 3.1
7.5 HighCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Updated
2026-11-02
OSVUBUNTU-CVE-2021-45958 5.5

UltraJSON (aka ujson) through 5.1.0 has a stack-based buffer overflow in Buffer_AppendIndentUnchecked (called from encode). Exploitation can, for example, use a large amount of indentation.

Record
UBUNTU-CVE-2021-45958
CVSS 3.1
5.5 MediumCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H
Updated
2026-11-02
OSVMGASA-2022-0169 No score

Updated python-ujson packages fix security vulnerability

UltraJSON (aka ujson) through 5.1.0 has a stack-based buffer overflow in Buffer_AppendIndentUnchecked (called from encode). Exploitation can, for example, use a large amount of indentation. (CVE-2021-45958)

Record
MGASA-2022-0169
Updated
2026-11-02
OSVopenSUSE-SU-2024:12106-1 No score

python310-ujson-5.3.0-1.1 on GA media

These are all security issues fixed in the python310-ujson-5.3.0-1.1 package on the GA media of openSUSE Tumbleweed.

Record
openSUSE-SU-2024:12106-1
Updated
2026-11-02
OSVopenSUSE-SU-2025:15107-1 No score

python311-ujson-5.10.0-1.5 on GA media

These are all security issues fixed in the python311-ujson-5.10.0-1.5 package on the GA media of openSUSE Tumbleweed.

Record
openSUSE-SU-2025:15107-1
Updated
2026-11-02
OSVPYSEC-2022-25 No score

UltraJSON (aka ujson) through 5.1.0 has a stack-based buffer overflow in Buffer_AppendIndentUnchecked (called from encode). Exploitation can, for example, use a large amount of indentation.

Record
PYSEC-2022-25
Updated
2026-11-02
OSVSUSE-SU-2023:2134-1 No score

Security update for python-ujson

This update for python-ujson fixes the following issues:

  • CVE-2021-45958: Fixed a stack-based buffer overflow in Buffer_AppendIndentUnchecked (bsc#1194261).
Record
SUSE-SU-2023:2134-1
Updated
2026-11-02
OSVUSN-6629-1 No score

ujson vulnerabilities

It was discovered that UltraJSON incorrectly handled certain input with a large amount of indentation. An attacker could possibly use this issue to crash the program, resulting in a denial of service. (CVE-2021-45958)

Jake Miller discovered that UltraJSON incorrectly decoded certain characters. An attacker could possibly use this issue to cause key confusion and overwrite values in dictionaries. (CVE-2022-31116)

It was discovered that UltraJSON incorrectly handled an error when reallocating a buffer for string decoding. An attacker could possibly use this issue to corrupt memory. (CVE-2022-31117)

Record
USN-6629-1
Updated
2026-11-02
OSVUSN-6629-2 No score

ujson vulnerability

USN-6629-1 fixed vulnerabilities in UltraJSON. This update provides the corresponding updates for Ubuntu 20.04 LTS.

Original advisory details:

It was discovered that UltraJSON incorrectly handled certain input with a large amount of indentation. An attacker could possibly use this issue to crash the program, resulting in a denial of service. (CVE-2021-45958)

Jake Miller discovered that UltraJSON incorrectly decoded certain characters. An attacker could possibly use this issue to cause key confusion and overwrite values in dictionaries. (CVE-2022-31116)

It was discovered that UltraJSON incorrectly handled an error when reallocating a buffer for string decoding. An attacker could possibly use this issue to corrupt memory. (CVE-2022-31117)

Record
USN-6629-2
Updated
2026-11-02

Affected products

Affected packages

Affected packages
PackageAffectedFixed
ujson
PyPI
1.34 up to 5.2.0
5.2.0
py3-ujson
Alpine:v3.16
before 5.2.0-r0
5.2.0-r0
py3-ujson
Alpine:v3.17
before 5.2.0-r0
5.2.0-r0
py3-ujson
Alpine:v3.18
before 5.2.0-r0
5.2.0-r0
py3-ujson
Alpine:v3.19
before 5.2.0-r0
5.2.0-r0
py3-ujson
Alpine:v3.20
before 5.2.0-r0
5.2.0-r0
py3-ujson
Alpine:v3.21
before 5.2.0-r0
5.2.0-r0
py3-ujson
Alpine:v3.22
before 5.2.0-r0
5.2.0-r0
py3-ujson
Alpine:v3.23
before 5.2.0-r0
5.2.0-r0
py3-ujson
Alpine:v3.24
before 5.2.0-r0
5.2.0-r0
Show 32 moreShow less
Affected packages
PackageAffectedFixed
ujson
Debian:12
before 5.2.0-1
5.2.0-1
ujson
Debian:13
before 5.2.0-1
5.2.0-1
ujson
Debian:14
before 5.2.0-1
5.2.0-1
ujson
Debian:9
before 1.35-1+deb9u1, plus listed versions
1.35-1
1.35-1+deb9u1
ujson
PyPI
1.34 up to 5.2.0, plus listed versions
1.352.0.02.0.12.0.22.0.3
Show 11 moreShow less
3.0.03.1.03.2.04.0.04.0.14.0.24.1.04.2.04.3.05.0.05.1.0
5.2.0
python-ujson
Mageia:8
before 5.2.0-1.mga8
5.2.0-1.mga8
python-ujson
openEuler:20.03-LTS-SP4
From an advisory covering 5 CVEs
before 4.0.2-3.oe2003sp4
4.0.2-3.oe2003sp4
python-ujson
openEuler:24.03-LTS-SP1
From an advisory covering 4 CVEs
before 5.1.0-6.oe2403sp1
5.1.0-6.oe2403sp1
python-ujson
openEuler:24.03-LTS-SP3
From an advisory covering 4 CVEs
before 5.1.0-7.oe2403sp3
5.1.0-7.oe2403sp3
python-ujson
openEuler:24.03-LTS-SP4
From an advisory covering 4 CVEs
before 5.1.0-6.oe2403sp4
5.1.0-6.oe2403sp4
ujson
PyPI
4.0.2 up to 5.1.0, plus listed versions
4.1.04.2.04.3.05.0.0
5.1.0
python-ujson
SUSE:Linux Enterprise Module for Development Tools 15 SP4
before 1.35-150100.3.8.1
1.35-150100.3.8.1
python-ujson
SUSE:Linux Enterprise Module for Package Hub 15 SP4
before 1.35-150100.3.8.1
1.35-150100.3.8.1
python-ujson
SUSE:Linux Enterprise Real Time 15 SP3
before 1.35-150100.3.8.1
1.35-150100.3.8.1
python-ujson
openSUSE:Leap 15.4
before 1.35-150100.3.8.1
1.35-150100.3.8.1
pandas
Ubuntu:14.04:LTS
All versions, plus listed versions
0.12.0-2ubuntu10.13.1-2ubuntu10.13.1-2ubuntu2
None known
ujson
Ubuntu:Pro:16.04:LTS
before 1.33-1ubuntu0.1~esm2, plus listed versions
1.33-11.33-1build1
1.33-1ubuntu0.1~esm2
pandas
Ubuntu:16.04:LTS
All versions, plus listed versions
0.15.0-20.15.0-2ubuntu10.15.0-2ubuntu20.17.1-3ubuntu2
None known
pandas
Ubuntu:18.04:LTS
All versions, plus listed versions
0.19.2-5.1ubuntu40.22.0-2ubuntu10.22.0-30.22.0-40.22.0-4ubuntu1
None known
ujson
Ubuntu:Pro:18.04:LTS
before 1.35-2ubuntu0.1~esm1, plus listed versions
1.35-1build21.35-2
1.35-2ubuntu0.1~esm1
ujson
Ubuntu:20.04:LTS
before 1.35-4ubuntu0.1, plus listed versions
1.35-3build11.35-3build21.35-41.35-4build1
1.35-4ubuntu0.1
pandas
Ubuntu:20.04:LTS
All versions, plus listed versions
0.23.3+dfsg-4ubuntu10.23.3+dfsg-4ubuntu50.23.3+dfsg-4ubuntu60.25.3+dfsg-40.25.3+dfsg-4build10.25.3+dfsg-7
None known
pandas
Ubuntu:22.04:LTS
All versions, plus listed versions
1.1.5+dfsg-21.1.5+dfsg-2ubuntu11.3.5+dfsg-21.3.5+dfsg-2ubuntu11.3.5+dfsg-3
None known
ujson
Ubuntu:Pro:22.04:LTS
before 5.1.0-1ubuntu0.1~esm1, plus listed versions
4.0.2-14.0.2-1build14.2.0-15.1.0-15.1.0-1build1
5.1.0-1ubuntu0.1~esm1
pandas
Ubuntu:24.04:LTS
All versions, plus listed versions
1.5.3+dfsg-61.5.3+dfsg-6ubuntu11.5.3+dfsg-7ubuntu11.5.3+dfsg-102.1.4+dfsg-4ubuntu22.1.4+dfsg-7
None known
pandas
Ubuntu:25.10
All versions, plus listed versions
2.2.3+dfsg-8build12.2.3+dfsg-9
None known
pandas
Ubuntu:26.10
All versions, plus listed versions
2.3.3+dfsg-3ubuntu12.3.3+dfsg-3ubuntu3
None known
pandas
Ubuntu:26.04:LTS
All versions, plus listed versions
2.2.3+dfsg-92.3.3+dfsg-1ubuntu12.3.3+dfsg-32.3.3+dfsg-3ubuntu1
None known
ujson
Ubuntu:Pro:16.04:LTS
From an advisory covering 3 CVEs
before 1.33-1ubuntu0.1~esm2, plus listed versions
1.33-11.33-1build1
1.33-1ubuntu0.1~esm2
ujson
Ubuntu:Pro:18.04:LTS
From an advisory covering 3 CVEs
before 1.35-2ubuntu0.1~esm1, plus listed versions
1.35-1build21.35-2
1.35-2ubuntu0.1~esm1
ujson
Ubuntu:Pro:22.04:LTS
From an advisory covering 3 CVEs
before 5.1.0-1ubuntu0.1~esm1, plus listed versions
4.0.2-14.0.2-1build14.2.0-15.1.0-15.1.0-1build1
5.1.0-1ubuntu0.1~esm1
python-ujson
openSUSE:Tumbleweed
From an advisory covering 3 CVEs
before 5.10.0-1.5
5.10.0-1.5

History

History
RecordedChangedSources
affected, facts
affected, aliases, referencesOSV
aliasesEUVD
first indexedCVE List, GitHub Advisories, NVD, OSV

Dates are when Every CVE recorded each change. Upstream dates may differ.

In short

CVE-2021-45958 is a medium vulnerability (CVSS 5.5) in Ultrajson Project Ultrajson, published December 31, 2021. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 1.67%, the 76th percentile. Fixed in ujson 5.2.0.

References

Show 40 moreShow less
MoveEnter Open