CVE-2021-29553: Tensorflow gpu Heap OOB Vulnerability
LOWCVE-2021-29553 is a LOW (CVSS 2.5) heap oob vulnerability (CWE-125: Out-of-bounds Read) affecting Tensorflow gpu libraries in the PyPI ecosystem. The issue involves heap oob in `quantizeanddequantizev3`. Remediation is available by upgrading affected packages to version 2.3.3, 2.4.2, 2.1.4, 2.2.3.
CVE-2021-29553 at a Glance
Security Impact
CVSS: 2.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:L).
How to Fix CVE-2021-29553
To remediate this vulnerability, upgrade all affected Tensorflow gpu dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install tensorflow-gpu>=2.3.3
pip install tensorflow>=2.3.3
pip install tensorflow>=2.4.2
pip install tensorflow-cpu>=2.1.4
pip install tensorflow-cpu>=2.2.3
pip install tensorflow-gpu>=2.4.2
pip install tensorflow-cpu>=2.3.3
pip install tensorflow-cpu>=2.4.2
pip install tensorflow-gpu>=2.1.4
pip install tensorflow>=2.1.4
pip install tensorflow>=2.2.3
pip install tensorflow-gpu>=2.2.3
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show tensorflow-gpu
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2021-29553, inspect your installed packages using pip:
pip show tensorflow-gpu
Analyze the terminal output to locate any version of Tensorflow gpu in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.3.3), your application is affected.
Note: The pip show tensorflow-gpu command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-125: Out-of-bounds Read, where the product reads data past the end, or before the beginning, of the intended buffer. In Tensorflow gpu, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2021-29553 Affected Tensorflow gpu Versions
12 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
tensorflow-gpu
|
PyPI |
≥ 2.3.0
< 2.3.3
|
2.3.3
|
|
tensorflow
|
PyPI |
≥ 2.3.0
< 2.3.3
|
2.3.3
|
|
tensorflow
|
PyPI |
≥ 2.4.0
< 2.4.2
|
2.4.2
|
|
tensorflow-cpu
|
PyPI |
< 2.1.4
|
2.1.4
|
|
tensorflow-cpu
|
PyPI |
≥ 2.2.0
< 2.2.3
|
2.2.3
|
|
tensorflow-gpu
|
PyPI |
< 2.4.2
≥ 2.4.0
|
2.4.2
|
|
tensorflow-cpu
|
PyPI |
≥ 2.3.0
< 2.3.3
|
2.3.3
|
|
tensorflow-cpu
|
PyPI |
≥ 2.4.0
< 2.4.2
|
2.4.2
|
|
tensorflow-gpu
|
PyPI |
< 2.1.4
|
2.1.4
|
|
tensorflow
|
PyPI |
< 2.1.4
|
2.1.4
|
|
tensorflow
|
PyPI |
≥ 2.2.0
< 2.2.3
|
2.2.3
|
|
tensorflow-gpu
|
PyPI |
≥ 2.2.0
< 2.2.3
|
2.2.3
|
References
Frequently Asked Questions
What is CVE-2021-29553?
Which Tensorflow gpu versions are affected?
What version fixes CVE-2021-29553?
Is tensorflow-gpu affected?
Is tensorflow affected?
What is the CVSS score of CVE-2021-29553?
What CWE is associated with CVE-2021-29553?
How can I check PyPI dependencies for CVE-2021-29553?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-h9px-9vqg-222h",
"modified" : "2024-10-31T20:51:10Z",
"published" : "2021-05-21T14:23:51Z",
"aliases" : [ "CVE-2021-29553" ],
"summary" : "Heap OOB in `QuantizeAndDequantizeV3`",
"details" : "### Impact\nAn attacker can read data outside of bounds of heap allocated buffer in `tf.raw_ops.QuantizeAndDequantizeV3`:\n\n```python\nimport tensorflow as tf\n\ntf.raw_ops.QuantizeAndDequantizeV3(\n input=[2.5,2.5], input_min=[0,0], input_max=[1,1], num_bits=[30],\n signed_input=False, range_given=False, narrow_range=False, axis=3)\n``` \n\nThis is because the [implementation](https://github.com/tensorflow/tensorflow/blob/11ff7f80667e6490d7b5174aa6bf5e01886e770f/tensorflow/core/kernels/quantize_and_dequantize_op.cc#L237) does not validate the value of user supplied `axis` attribute before using it to index in the array backing the `input` argument:\n\n```cc\nconst int depth = (axis_ == -1) ? 1 : input.dim_size(axis_);\n```\n\n### Patches\nWe have patched the issue in GitHub commit [99085e8ff02c3763a0ec2263e44daec416f6a387](https://github.com/tensorflow/tensorflow/commit/99085e8ff02c3763a0ec2263e44daec416f6a387).\n \nThe 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.\n\n### For more information\nPlease consult [our security guide](https://github.com/tensorflow/tensorflow/blob/master/SECURITY.md) for more information regarding the security model and how to contact us with issues and questions.\n\n### Attribution\nThis vulnerability has been reported by Aivul Team from Qihoo 360.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:L"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "tensorflow"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "2.1.4"
} ]
} ]
}, {
"package" : {
"ecosystem" : "PyPI",
"name" : "tensorflow"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.2.0"
}, {
"fixed" : "2.2.3"
} ]
} ]
}, {
"package" : {
"ecosystem" : "PyPI",
"name" : "tensorflow"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.3.0"
}, {
"fixed" : "2.3.3"
} ]
} ]
}, {
"package" : {
"ecosystem" : "PyPI",
"name" : "tensorflow"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.4.0"
}, {
"fixed" : "2.4.2"
} ]
} ]
}, {
"package" : {
"ecosystem" : "PyPI",
"name" : "tensorflow-cpu"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "2.1.4"
} ]
} ]
}, {
"package" : {
"ecosystem" : "PyPI",
"name" : "tensorflow-cpu"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.2.0"
}, {
"fixed" : "2.2.3"
} ]
} ]
}, {
"package" : {
"ecosystem" : "PyPI",
"name" : "tensorflow-cpu"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.3.0"
}, {
"fixed" : "2.3.3"
} ]
} ]
}, {
"package" : {
"ecosystem" : "PyPI",
"name" : "tensorflow-cpu"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.4.0"
}, {
"fixed" : "2.4.2"
} ]
} ]
}, {
"package" : {
"ecosystem" : "PyPI",
"name" : "tensorflow-gpu"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "2.1.4"
} ]
} ]
}, {
"package" : {
"ecosystem" : "PyPI",
"name" : "tensorflow-gpu"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.2.0"
}, {
"fixed" : "2.2.3"
} ]
} ]
}, {
"package" : {
"ecosystem" : "PyPI",
"name" : "tensorflow-gpu"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.3.0"
}, {
"fixed" : "2.3.3"
} ]
} ]
}, {
"package" : {
"ecosystem" : "PyPI",
"name" : "tensorflow-gpu"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.4.0"
}, {
"fixed" : "2.4.2"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/tensorflow/tensorflow/security/advisories/GHSA-h9px-9vqg-222h"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-29553"
}, {
"type" : "WEB",
"url" : "https://github.com/tensorflow/tensorflow/commit/99085e8ff02c3763a0ec2263e44daec416f6a387"
}, {
"type" : "WEB",
"url" : "https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow-cpu/PYSEC-2021-481.yaml"
}, {
"type" : "WEB",
"url" : "https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow-gpu/PYSEC-2021-679.yaml"
}, {
"type" : "WEB",
"url" : "https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow/PYSEC-2021-190.yaml"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/tensorflow/tensorflow"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-125" ],
"severity" : "LOW",
"github_reviewed" : true,
"github_reviewed_at" : "2021-05-18T20:59:57Z",
"nvd_published_at" : "2021-05-14T20:15:00Z"
}
}