7.1high
Heap OOB read in shape inference for `QuantizeV2`
- Severity
- 7.1high CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.21% (higher than 6% of CVEs)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-cvgx-3v3q-m36cBIT-TENSORFLOW-2021-41211PYSEC-2021-403PYSEC-2021-620PYSEC-2021-818
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.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| tensorflow tensorflow | >= 2.6.0, < 2.6.1 | CVE List |
| tensorflow (PyPI) | from 2.6.0 before 2.6.1, before a0d64445116c43cf46a5666bd4eee28e7a82f244, from 2.7.0rc0 before 2.7.0 | GitHub Advisory Database, PyPA Advisory Database |
| tensorflow-cpu (PyPI) | from 2.6.0 before 2.6.1, before a0d64445116c43cf46a5666bd4eee28e7a82f244, from 2.7.0rc0 before 2.7.0 | GitHub Advisory Database, PyPA Advisory Database |
| tensorflow-gpu (PyPI) | from 2.6.0 before 2.6.1, before a0d64445116c43cf46a5666bd4eee28e7a82f244, from 2.7.0rc0 before 2.7.0 | GitHub Advisory Database, PyPA Advisory Database |
| google tensorflow | 2.6.0 | NVD |
| tensorflow (Bitnami) | from 2.6.0 before 2.6.1 | Bitnami Vulnerability Database |
All scores
| GitHub_M | 7.1high CVSS:3.1 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:H |
| GitHub | 7.1high CVSS:3.1 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:H |
| NVD | 7.1high CVSS:3.1 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:H |
| NVD | 3.6low CVSS:2.0 | AV:L/AC:L/Au:N/C:P/I:N/A:P |
| Bitnami Vulnerability Database | high rating |
Classification
What each source says
CVE List
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.
GitHub Advisory Database
Impact
The shape inference code for QuantizeV2 can trigger a read outside of bounds of heap allocated array:
import tensorflow as tf
@tf.function
def test():
data=tf.raw_ops.QuantizeV2(
input=[1.0,1.0],
min_range=[1.0,10.0],
max_range=[1.0,10.0],
T=tf.qint32,
mode='MIN_COMBINED',
round_mode='HALF_TO_EVEN',
narrow_range=False,
axis=-100,
ensure_minimum_range=10)
return data
test()
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:
int axis = -1;
Status s = c->GetAttr("axis", &axis);
if (!s.ok() && s.code() != error::NOT_FOUND) {
return s;
}
...
if (axis != -1) {
...
TF_RETURN_IF_ERROR(
c->Merge(c->Dim(minmax, 0), c->Dim(input, axis), &depth));
}
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.
Patches
We have patched the issue in GitHub commit a0d64445116c43cf46a5666bd4eee28e7a82f244.
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.
For more information
Please consult our security guide for more information regarding the security model and how to contact us with issues and questions.
Attribution
This vulnerability has been reported by members of the Aivul Team from Qihoo 360.
NVD (es)
TensorFlow es una plataforma de código abierto para el aprendizaje automático. En las versiones afectadas, el código de inferencia de forma para "QuantizeV2" puede desencadenar una lectura fuera de límites de la matriz asignada a la pila. Esto ocurre siempre que el "eje" es un valor negativo menor que "1". En este caso, estamos accediendo a los datos antes del inicio de un buffer de heap. El código permite que "axis" sea un argumento opcional ("s" contendría un código de error "error::NOT_FOUND"). En caso contrario, asume que "axis" es un índice válido en las dimensiones del tensor "input". Si "axis" es menor que "-1", se produce una lectura OOB de la pila. La corrección será incluida en TensorFlow versión 2.7.0. También vamos a incluir este commit en TensorFlow versión 2.6.1, ya que esta versión es la única que también está afectada
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2021-41211 changed 2024-08-04 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-cvgx-3v3q-m36c changed 2026-07-08 | CC-BY-4.0 |
| NVD | CVE-2021-41211 changed 2026-06-17 | Public domain |
| PyPA Advisory Database | PYSEC-2021-403 changed 2023-12-06 | CC-BY-4.0 |
| PyPA Advisory Database | PYSEC-2021-620 changed 2023-12-06 | CC-BY-4.0 |
| PyPA Advisory Database | PYSEC-2021-818 changed 2023-12-06 | CC-BY-4.0 |
| Bitnami Vulnerability Database | BIT-TENSORFLOW-2021-41211 changed 2026-09-08 | Apache-2.0 |