CVE-2021-37670: Heap OOB in `UpperBound` and `LowerBound` in TensorFlow
Impact An attacker can read from outside of bounds of heap allocated data by sending specially crafted illegal arguments to tf.rawops.UpperBound:
python import tensorflow as tf tf.rawops.UpperBound( sortedinput=[1,2,3], values=tf.constant(value=[[0,0,0],[1,1,1],[2,2,2]],dtype=tf.int64), outtype=tf.int64) The implementation does not validate the rank of sortedinput argument:
cc void Compute(OpKernelContext ctx) override { const Tensor& sortedinputst = ctx->input(0); // ... OPREQUIRES(ctx, sortedinputst.dimsize(0) == valuest.dimsize(0), Status(error::INVALIDARGUMENT, "Leading dimsize of both tensors must match.")); // ... if (outputt->dtype() == DTINT32) { OPREQUIRES(ctx, FastBoundsCheck(sortedinputst.dimsize(1), ...)); // ... }
As we access the first two dimensions of sortedinputst tensor, it must have rank at least 2.
A similar issue occurs in tf.rawops.LowerBound.
Patches We have patched the issue in GitHub commit 42459e4273c2e47a3232cc16c4f4fff3b3a35c38. The fix will be included in TensorFlow 2.6.0. We will also cherrypick this commit on TensorFlow 2.5.1, TensorFlow 2.4.3, and TensorFlow 2.3.4, 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 members of the Aivul Team from Qihoo 360.
Other sources
TensorFlow is an end-to-end open source platform for machine learning. In affected versions an attacker can read from outside of bounds of heap allocated data by sending specially crafted illegal arguments to tf.rawops.UpperBound. The implementation does not validate the rank of sortedinput argument. A similar issue occurs in tf.rawops.LowerBound. We have patched the issue in GitHub commit 42459e4273c2e47a3232cc16c4f4fff3b3a35c38. The fix will be included in TensorFlow 2.6.0. We will also cherrypick this commit on TensorFlow 2.5.1, TensorFlow 2.4.3, and TensorFlow 2.3.4, as these are also affected and still in supported range.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pip/tensorflow-gputo a version that resolves this vulnerability.Fixed in 2.5.1 - Upgrade
Upgrade
pip/tensorflow-gputo a version that resolves this vulnerability.Fixed in 2.4.3 - Upgrade
Upgrade
pip/tensorflow-gputo a version that resolves this vulnerability.Fixed in 2.3.4 - Upgrade
Upgrade
pip/tensorflow-cputo a version that resolves this vulnerability.Fixed in 2.5.1 - Upgrade
Upgrade
pip/tensorflow-cputo a version that resolves this vulnerability.Fixed in 2.4.3 - Upgrade
Upgrade
pip/tensorflow-cputo a version that resolves this vulnerability.Fixed in 2.3.4 - Upgrade
Upgrade
pip/tensorflowto a version that resolves this vulnerability.Fixed in 2.5.1 - Upgrade
Upgrade
pip/tensorflowto a version that resolves this vulnerability.Fixed in 2.4.3 - Upgrade
Upgrade
pip/tensorflowto a version that resolves this vulnerability.Fixed in 2.3.4 - Upgrade
Upgrade
tensorflowto a version that resolves this vulnerability.Fixed in 2.6.0Patch 42459e4273c2e47a3232cc16c4f4fff3b3a35c38 - Upgrade
Upgrade
tensorflowto a version that resolves this vulnerability.Fixed in 2.5.1Patch 42459e4273c2e47a3232cc16c4f4fff3b3a35c38 - Upgrade
Upgrade
tensorflowto a version that resolves this vulnerability.Fixed in 2.4.3Patch 42459e4273c2e47a3232cc16c4f4fff3b3a35c38 - Upgrade
Upgrade
tensorflowto a version that resolves this vulnerability.Fixed in 2.3.4Patch 42459e4273c2e47a3232cc16c4f4fff3b3a35c38
Event History
Frequently Asked Questions
What is the severity of CVE-2021-37670?
CVE-2021-37670 has a severity rating that indicates a potential risk of heap memory corruption due to out-of-bounds read.
How do I fix CVE-2021-37670?
To address CVE-2021-37670, upgrade to TensorFlow versions 2.5.1 or 2.4.3, or apply the latest patches available.
Which versions of TensorFlow are affected by CVE-2021-37670?
CVE-2021-37670 affects TensorFlow versions 2.3.0 to 2.3.4, 2.4.0 to 2.4.3, and specific release candidates of 2.6.0.
What type of attack is possible with CVE-2021-37670?
An attacker can exploit CVE-2021-37670 by sending specially crafted illegal arguments to the `tf.raw_ops.UpperBound` operation.
Is CVE-2021-37670 related to any specific functionality in TensorFlow?
Yes, CVE-2021-37670 is related to the operation of bounds checking in the `tf.raw_ops.UpperBound` function.