CVE-2021-29580: Tensorflow Undefined Behavior And `CHECK`-fail Vulnerability
LOWCVE-2021-29580 is a LOW (CVSS 2.5) undefined behavior and `check`-fail vulnerability (CWE-908: Use of Uninitialized Resource) affecting Tensorflow libraries in the PyPI ecosystem. The issue involves undefined behavior and `check`-fail in `fractionalmaxpoolgrad`. Remediation is available by upgrading affected packages to version 2.1.4, 2.2.3, 2.3.3, 2.4.2.
CVE-2021-29580 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-29580
To remediate this vulnerability, upgrade all affected Tensorflow 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>=2.1.4
pip install tensorflow>=2.2.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-cpu>=2.3.3
pip install tensorflow-cpu>=2.4.2
pip install tensorflow-gpu>=2.1.4
pip install tensorflow-gpu>=2.2.3
pip install tensorflow-gpu>=2.3.3
pip install tensorflow-gpu>=2.4.2
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show tensorflow
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2021-29580, inspect your installed packages using pip:
pip show tensorflow
Analyze the terminal output to locate any version of Tensorflow in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.1.4), your application is affected.
Note: The pip show tensorflow command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-908: Use of Uninitialized Resource, where the product uses or accesses a resource that has not been initialized. In Tensorflow, 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-29580 Affected Tensorflow Versions
12 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
tensorflow
|
PyPI |
< 2.1.4
|
2.1.4
|
|
tensorflow
|
PyPI |
≥ 2.2.0
< 2.2.3
|
2.2.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-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-gpu
|
PyPI |
≥ 2.2.0
< 2.2.3
|
2.2.3
|
|
tensorflow-gpu
|
PyPI |
≥ 2.3.0
< 2.3.3
|
2.3.3
|
|
tensorflow-gpu
|
PyPI |
≥ 2.4.0
< 2.4.2
|
2.4.2
|
References
Frequently Asked Questions
What is CVE-2021-29580?
Which Tensorflow versions are affected?
What version fixes CVE-2021-29580?
Is tensorflow affected?
Is tensorflow-cpu affected?
What is the CVSS score of CVE-2021-29580?
What CWE is associated with CVE-2021-29580?
How can I check PyPI dependencies for CVE-2021-29580?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-x8h6-xgqx-jqgp",
"modified" : "2024-11-01T17:13:23Z",
"published" : "2021-05-21T14:26:26Z",
"aliases" : [ "CVE-2021-29580" ],
"summary" : "Undefined behavior and `CHECK`-fail in `FractionalMaxPoolGrad`",
"details" : "### Impact\nThe implementation of `tf.raw_ops.FractionalMaxPoolGrad` triggers an undefined behavior if one of the input tensors is empty:\n\n```python\nimport tensorflow as tf\n\norig_input = tf.constant([2, 3], shape=[1, 1, 1, 2], dtype=tf.int64)\norig_output = tf.constant([], dtype=tf.int64) \nout_backprop = tf.zeros([2, 3, 6, 6], dtype=tf.int64)\nrow_pooling_sequence = tf.constant([0], shape=[1], dtype=tf.int64)\ncol_pooling_sequence = tf.constant([0], shape=[1], dtype=tf.int64)\n\ntf.raw_ops.FractionalMaxPoolGrad(\n orig_input=orig_input, orig_output=orig_output, out_backprop=out_backprop,\n row_pooling_sequence=row_pooling_sequence,\n col_pooling_sequence=col_pooling_sequence, overlapping=False)\n```\n\nThe code is also vulnerable to a denial of service attack as a `CHECK` condition becomes false and aborts the process\n\n```python\nimport tensorflow as tf\n\norig_input = tf.constant([1], shape=[1], dtype=tf.int64)\norig_output = tf.constant([1], shape=[1], dtype=tf.int64)\nout_backprop = tf.constant([1, 1], shape=[2, 1, 1, 1], dtype=tf.int64)\nrow_pooling_sequence = tf.constant([1], shape=[1], dtype=tf.int64) \ncol_pooling_sequence = tf.constant([1], shape=[1], dtype=tf.int64)\n\ntf.raw_ops.FractionalMaxPoolGrad(\n orig_input=orig_input, orig_output=orig_output, out_backprop=out_backprop,\n row_pooling_sequence=row_pooling_sequence,\n col_pooling_sequence=col_pooling_sequence, overlapping=False)\n``` \n\nThe [implementation](https://github.com/tensorflow/tensorflow/blob/169054888d50ce488dfde9ca55d91d6325efbd5b/tensorflow/core/kernels/fractional_max_pool_op.cc#L215) fails to validate that input and output tensors are not empty and are of the same rank. Each of these unchecked assumptions is responsible for the above issues.\n\n### Patches\nWe have patched the issue in GitHub commit [32fdcbff9d06d010d908fcc4bd4b36eb3ce15925](https://github.com/tensorflow/tensorflow/commit/32fdcbff9d06d010d908fcc4bd4b36eb3ce15925).\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 Ying Wang and Yakun Zhang of Baidu X-Team.",
"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-x8h6-xgqx-jqgp"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-29580"
}, {
"type" : "WEB",
"url" : "https://github.com/tensorflow/tensorflow/commit/32fdcbff9d06d010d908fcc4bd4b36eb3ce15925"
}, {
"type" : "WEB",
"url" : "https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow-cpu/PYSEC-2021-508.yaml"
}, {
"type" : "WEB",
"url" : "https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow-gpu/PYSEC-2021-706.yaml"
}, {
"type" : "WEB",
"url" : "https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow/PYSEC-2021-217.yaml"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/tensorflow/tensorflow"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-908" ],
"severity" : "LOW",
"github_reviewed" : true,
"github_reviewed_at" : "2021-05-18T17:53:08Z",
"nvd_published_at" : "2021-05-14T20:15:00Z"
}
}