CVE-2022-21727
JSON

7.6high

Integer overflow in Tensorflow

Severity
7.6high CVSS:3.1 by GitHub_M
Exploit likelihood
0.69% (higher than 53% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-c6fh-56w7-fvjwBIT-TENSORFLOW-2022-21727PYSEC-2022-106PYSEC-2022-51PYSEC-2026-3159

Description

Tensorflow is an Open Source Machine Learning Framework. The implementation of shape inference for `Dequantize` is vulnerable to an integer overflow weakness. The `axis` argument can be `-1` (the default value for the optional argument) or any other positive value at most the number of dimensions of the input. Unfortunately, the upper bound is not checked, and, since the code computes `axis + 1`, an attacker can trigger an integer overflow. The fix will be included in TensorFlow 2.8.0. We will also cherrypick this commit on TensorFlow 2.7.1, TensorFlow 2.6.3, and TensorFlow 2.5.3, as these are also affected and still in supported range.

Affected

Product or packageVersionsReported by
Unspecified productn/aCVE List
tensorflow (PyPI)before 2.5.3, from 2.6.0 before 2.6.3, from 2.7.0 before 2.7.1GitHub Advisory Database, PyPA Advisory Database
tensorflow-cpu (PyPI)before 2.5.3, from 2.6.0 before 2.6.3, from 2.7.0 before 2.7.1, before b64638ec5ccaa77b7c1eb90958e3d85ce381f91bGitHub Advisory Database, PyPA Advisory Database
tensorflow-gpu (PyPI)before 2.5.3, from 2.6.0 before 2.6.3, from 2.7.0 before 2.7.1, before b64638ec5ccaa77b7c1eb90958e3d85ce381f91bGitHub Advisory Database, PyPA Advisory Database
google tensorflowup to 2.5.2, from 2.6.0 up to 2.6.2, 2.7.0NVD
tensorflow (Bitnami)before 2.5.3, from 2.6.0 before 2.6.3, from 2.7.0 before 2.7.1Bitnami Vulnerability Database

All scores

GitHub_M7.6high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:H
GitHub7.6high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:H
GitHubhigh CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:L/VI:L/VA:H/SC:N/SI:N/SA:N
NVD8.8high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
NVD6.5medium CVSS:2.0AV:N/AC:L/Au:S/C:P/I:P/A:P
PyPA Advisory Database7.6high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:H
PyPA Advisory DatabaseNot scored CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:L/VI:L/VA:H/SC:N/SI:N/SA:N
Bitnami Vulnerability Databasehigh rating

Classification

CWE-190

SSVC (CISA-ADP): exploitation poc, automatable no, technical impact partial.

What each source says

CVE List

Tensorflow is an Open Source Machine Learning Framework. The implementation of shape inference for `Dequantize` is vulnerable to an integer overflow weakness. The `axis` argument can be `-1` (the default value for the optional argument) or any other positive value at most the number of dimensions of the input. Unfortunately, the upper bound is not checked, and, since the code computes `axis + 1`, an attacker can trigger an integer overflow. The fix will be included in TensorFlow 2.8.0. We will also cherrypick this commit on TensorFlow 2.7.1, TensorFlow 2.6.3, and TensorFlow 2.5.3, as these are also affected and still in supported range.

GitHub Advisory Database
Impact

The implementation of shape inference for Dequantize is vulnerable to an integer overflow weakness:

import tensorflow as tf

input = tf.constant([1,1],dtype=tf.qint32)

@tf.function
def test():
  y = tf.raw_ops.Dequantize(
    input=input,
    min_range=[1.0],
    max_range=[10.0],
    mode='MIN_COMBINED',
    narrow_range=False,
    axis=2**31-1,
    dtype=tf.bfloat16)
  return y

test()

The axis argument can be -1 (the default value for the optional argument) or any other positive value at most the number of dimensions of the input. Unfortunately, the upper bound is not checked, and, since the code computes axis + 1, an attacker can trigger an integer overflow:

  int axis = -1; 
  Status s = c->GetAttr("axis", &axis);
  // ...
  if (axis < -1) {
    return errors::InvalidArgument("axis should be at least -1, got ",
                                   axis);
  }
  // ...
  if (axis != -1) {
    ShapeHandle input;
    TF_RETURN_IF_ERROR(c->WithRankAtLeast(c->input(0), axis + 1, &input));
    // ...
  }
Patches

We have patched the issue in GitHub commit b64638ec5ccaa77b7c1eb90958e3d85ce381f91b.

The fix will be included in TensorFlow 2.8.0. We will also cherrypick this commit on TensorFlow 2.7.1, TensorFlow 2.6.3, and TensorFlow 2.5.3, as these are also affected and still in supported range.

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 Yu Tian of Qihoo 360 AIVul Team.

NVD (es)

Tensorflow es un marco de aprendizaje automático de código abierto. La implementación de la inferencia de formas para "Dequantize" es vulnerable a una debilidad de desbordamiento de enteros. El argumento "axis" puede ser "-1" (el valor por defecto para el argumento opcional) o cualquier otro valor positivo como máximo el número de dimensiones de la entrada. Desafortunadamente, el límite superior no es comprobado y, dado que el código calcula "axis + 1", un atacante puede desencadenar un desbordamiento de enteros. La corrección será incluida en TensorFlow versión 2.8.0. También seleccionaremos este commit en TensorFlow versión 2.7.1, TensorFlow versión 2.6.3, y TensorFlow versión 2.5.3, ya que estos también están afectados y aún están en el rango admitido

References

https://github.com/tensorflow/tensorflow/security/advisories/GHSA-c6fh-56w7-fvjwadvisory, patch, third-party-advisory, web
https://github.com/tensorflow/tensorflow/commit/b64638ec5ccaa77b7c1eb90958e3d85ce381f91badvisory, fix, patch, third-party-advisory, web
https://github.com/tensorflow/tensorflow/blob/5100e359aef5c8021f2e71c7b986420b85ce7b3d/tensorflow/core/ops/array_ops.cc#L3001-L3034advisory, exploit, third-party-advisory, web
https://nvd.nist.gov/vuln/detail/CVE-2022-21727advisory, web
https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow-cpu/PYSEC-2022-51.yamlweb
https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow-gpu/PYSEC-2022-106.yamlweb
https://github.com/tensorflow/tensorflowweb
https://pypi.org/project/tensorflowpackage
https://github.com/advisories/GHSA-c6fh-56w7-fvjwadvisory

Sources

SourceRecordLicence
CVE ListCVE-2022-21727 changed 2025-05-05CVE Terms of Use
GitHub Advisory DatabaseGHSA-c6fh-56w7-fvjw changed 2026-07-13CC-BY-4.0
NVDCVE-2022-21727 changed 2026-06-17Public domain
PyPA Advisory DatabasePYSEC-2022-106 changed 2026-07-13CC-BY-4.0
PyPA Advisory DatabasePYSEC-2022-51 changed 2026-07-13CC-BY-4.0
PyPA Advisory DatabasePYSEC-2026-3159 changed 2026-07-13CC-BY-4.0
Bitnami Vulnerability DatabaseBIT-TENSORFLOW-2022-21727 changed 2026-09-08Apache-2.0