CVE-2021-45958: Ujson UltraJSON Vulnerable To Out-of-bounds Write Vulnerability
MODERATECVE-2021-45958 is a MODERATE (CVSS 5.5) ultrajson vulnerable to out-of-bounds write vulnerability (CWE-787: Out-of-bounds Write) affecting Ujson libraries in the PyPI ecosystem. The issue involves ultrajson vulnerable to out-of-bounds write. Remediation is available by upgrading affected packages to version 5.2.0.
CVE-2021-45958 at a Glance
Security Impact
CVSS: 5.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H).
How to Fix CVE-2021-45958
To remediate this vulnerability, upgrade all affected Ujson dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install ujson>=5.2.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show ujson
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2021-45958, inspect your installed packages using pip:
pip show ujson
Analyze the terminal output to locate any version of Ujson in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.2.0), your application is affected.
Note: The pip show ujson command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-787: Out-of-bounds Write, where the product writes data past the end, or before the beginning, of the intended buffer. In Ujson, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2021-45958 Affected Ujson Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
ujson
|
PyPI |
≥ 1.34
< 5.2.0
|
5.2.0
|
References
Frequently Asked Questions
What is CVE-2021-45958?
Which Ujson versions are affected?
What version fixes CVE-2021-45958?
Is ujson affected?
What is the CVSS score of CVE-2021-45958?
What CWE is associated with CVE-2021-45958?
How can I check PyPI dependencies for CVE-2021-45958?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-fh56-85cw-5pq6",
"modified" : "2024-11-18T22:47:32Z",
"published" : "2022-01-21T23:27:45Z",
"aliases" : [ "CVE-2021-45958" ],
"summary" : "UltraJSON vulnerable to Out-of-bounds Write",
"details" : "UltraJSON (aka ujson) 1.34 through 5.1.0 has a stack-based buffer overflow in Buffer_AppendIndentUnchecked (called from encode).",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "ujson"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "1.34"
}, {
"fixed" : "5.2.0"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-45958"
}, {
"type" : "WEB",
"url" : "https://github.com/ultrajson/ultrajson/issues/501"
}, {
"type" : "WEB",
"url" : "https://github.com/ultrajson/ultrajson/issues/502#issuecomment-1031747284"
}, {
"type" : "WEB",
"url" : "https://github.com/ultrajson/ultrajson/pull/504"
}, {
"type" : "WEB",
"url" : "https://github.com/ultrajson/ultrajson/pull/519"
}, {
"type" : "WEB",
"url" : "https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=36009"
}, {
"type" : "ADVISORY",
"url" : "https://github.com/advisories/GHSA-fh56-85cw-5pq6"
}, {
"type" : "WEB",
"url" : "https://github.com/google/oss-fuzz-vulns/blob/main/vulns/ujson/OSV-2021-955.yaml"
}, {
"type" : "WEB",
"url" : "https://github.com/pypa/advisory-database/tree/main/vulns/ujson/PYSEC-2022-25.yaml"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/ultrajson/ultrajson"
}, {
"type" : "WEB",
"url" : "https://lists.debian.org/debian-lts-announce/2022/02/msg00023.html"
}, {
"type" : "WEB",
"url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/CN7W3GOXALINKFUUE7ICQIC2EF5HNKUQ"
}, {
"type" : "WEB",
"url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/NAU5N4A7EUK2AMUCOLYDD5ARXAJYZBD2"
}, {
"type" : "WEB",
"url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/O6JUWQTJLA2CMG4CJN7DCUVSOXLZIIXL"
}, {
"type" : "WEB",
"url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/ULX35TSWLBBIMEH44MUORPXYYRZKEDC6"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-787" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2022-01-12T19:29:48Z",
"nvd_published_at" : "2022-01-01T00:15:00Z"
}
}