CVE-2021-29521
MEDIUM 5.5CVSS 3.1Segfault in SparseCountSparseOutput
TensorFlow is an end-to-end open source platform for machine learning. Specifying a negative dense shape in tf.raw_ops.SparseCountSparseOutput results in a segmentation fault being thrown out from the standard library as std::vector invariants are broken. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/8f7b60ee8c0206a2c99802e3a4d1bb55d2bc0624/tensorflow/core/kernels/count_ops.cc#L199-L213) assumes the first element of the dense shape is always positive and uses it to initialize a BatchedMap<T> (i.e., std::vector<absl::flat_hash_map<int64,T>>(https://github.com/tensorflow/tensorflow/blob/8f7b60ee8c0206a2c99802e3a4d1bb55d2bc0624/tensorflow/core/kernels/count_ops.cc#L27)) data structure. If the shape tensor has more than one element, num_batches is the first value in shape. Ensuring that the dense_shape argument is a valid tensor shape (that is, all elements are non-negative) solves this issue. The fix will be included in TensorFlow 2.5.0. We will also cherrypick this commit on TensorFlow 2.4.2 and TensorFlow 2.3.3.
- Published
- 14 May 2021
- Last modified
- 10 Sep 2026
- Assigned by
- security-advisories@github.com
- NVD status
- Modified
- Weakness
- CWE-131
- Also known as
- BIT-tensorflow-2021-29521GHSA-hr84-fqvp-48mmPYSEC-2021-158PYSEC-2021-449PYSEC-2021-647
- Sources
- NVDJSONOSV GHSA-hr84-fqvp-48mmJSONOSV PYSEC-2021-158JSONOSV PYSEC-2021-449JSONOSV PYSEC-2021-647JSON
Scores
| Source | Scored by | Version | Score | Vector / decision |
|---|---|---|---|---|
| OSV | GitHub | CVSS 4.0 | CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N | |
| NVD | nvd@nist.gov (Primary) | CVSS 3.1 | MEDIUM 5.5 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H |
| NVD | security-advisories@github.com (Secondary) | CVSS 3.1 | LOW 2.5 | CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:L |
| OSV | GitHub | CVSS 3.1 | LOW 2.5 | CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:L |
| NVD | nvd@nist.gov (Primary) | CVSS 2.0 | LOW 2.1 | AV:L/AC:L/Au:N/C:N/I:N/A:P |
Affected
| Source | Vendor / ecosystem | Product / package | Affected versions | Fixed in |
|---|---|---|---|---|
| NVD | tensorflowcpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:* |
>= 2.3.0, < 2.3.3 | 2.3.3 | |
| NVD | tensorflowcpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:* |
>= 2.4.0, < 2.4.2 | 2.4.2 | |
| OSV | PyPI | tensorflow | >= 2.3.0, < 2.3.3 | 2.3.3 |
| OSV | PyPI | tensorflow | >= 2.4.0, < 2.4.2 | 2.4.2 |
| OSV | PyPI | tensorflow-cpu | >= 2.3.0, < 2.3.3 | 2.3.3 |
| OSV | PyPI | tensorflow-cpu | >= 2.4.0, < 2.4.2 | 2.4.2 |
| OSV | PyPI | tensorflow-gpu | >= 2.3.0, < 2.3.3 | 2.3.3 |
| OSV | PyPI | tensorflow-gpu | >= 2.4.0, < 2.4.2 | 2.4.2 |
| OSV | PyPI | tensorflow | >= 2.3.0, < 2.3.3; >= 2.4.0, < 2.4.2 | 2.3.3, 2.4.2 |
| OSV | PyPI | tensorflow-cpu | >= 2.3.0, < 2.3.3; >= 2.4.0, < 2.4.2 | 2.3.3, 2.4.2 |
| OSV | PyPI | tensorflow-gpu | >= 2.3.0, < 2.3.3; >= 2.4.0, < 2.4.2 | 2.3.3, 2.4.2 |
References
- https://github.com/tensorflow/tensorflow/commit/c57c0b9f3a4f8684f3489dd9a9ec627ad8b599f5 · Patch, Third Party Advisory, WEB, FIX
- https://github.com/tensorflow/tensorflow/security/advisories/GHSA-hr84-fqvp-48mm · Exploit, Patch, Third Party Advisory, WEB, ADVISORY
- https://nvd.nist.gov/vuln/detail/CVE-2021-29521 · ADVISORY
- https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow-cpu/PYSEC-2021-449.yaml · WEB
- https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow-gpu/PYSEC-2021-647.yaml · WEB
- https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow/PYSEC-2021-158.yaml · WEB
History
- 25 Nov 2026 20:33 UTC · NVD: first stored (published 14 May 2021)
- 25 Nov 2026 20:12 UTC · OSV: first stored (published 14 May 2021)
- 25 Nov 2026 20:12 UTC · OSV: first stored (published 14 May 2021)
- 25 Nov 2026 20:12 UTC · OSV: first stored (published 14 May 2021)
- 25 Nov 2026 20:11 UTC · OSV: first stored (published 21 May 2021)