CVE-2022-21728: TensorFlow - Heap Out-of-Bounds Read in ReverseSequence Shape Inference
Summary
CVE-2022-21728: Out of bounds read in Tensorflow. Affects tensorflow across 3 version ranges.
< 2.5.3
>= 2.6.0, < 2.6.3
>= 2.7.0, < 2.7.1
Fixed in 2.5.3, 2.6.3 or 2.7.1, depending on the release line you run. How to fix ↓
Also tracked for
- tensorflow · PyPI
- tensorflow · PyPI
- tensorflow-gpu · PyPI
- tensorflow-cpu · PyPI
The same CVE-2022-21728 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
TensorFlow is an open-source machine learning framework developed by Google. It provides a comprehensive ecosystem for building and deploying machine learning models. TensorFlow supports various operations and functions for manipulating tensors, which are multi-dimensional arrays. One of these operations is ReverseSequence, which allows reversing the elements of a tensor along a specified dimension. However, the implementation of shape inference for ReverseSequence in TensorFlow has a vulnerability that can lead to a heap out-of-bounds read. This vulnerability arises due to insufficient validation of the batch_dim parameter, allowing negative values that can result in accessing elements before the start of an array.
Vulnerability Detail
The vulnerability in TensorFlow's ReverseSequence shape inference can be exploited by providing a negative value for the batch_dim parameter. While negative dimensions are allowed in some cases to mimic Python's negative indexing, if the value is too negative, it can lead to accessing elements before the start of an array. This can result in a heap out-of-bounds read, potentially leading to information disclosure or a crash. The issue has been assigned CVE-2022-21728 and has a CVSSv3 severity rating of High.
How To Fix
Fixed versions by release line
The minimum fixed version depends on the release line you run.
-
< 2.5.32.5.3 -
>= 2.6.0, < 2.6.32.6.3 -
>= 2.7.0, < 2.7.12.7.1
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
As a workaround, users can ensure that the batch_dim parameter passed to ReverseSequence is a non-negative value. By avoiding negative values, the vulnerability can be mitigated. Here's an example of how to check and enforce a non-negative batch_dim value in Python:
import tensorflow as tf
def reverse_sequence_with_non_negative_batch_dim(data, seq_lengths, batch_dim):
if batch_dim < 0:
raise ValueError('batch_dim must be non-negative')
return tf.reverse_sequence(data, seq_lengths, batch_dim)
Conclusion
The vulnerability in TensorFlow's ReverseSequence shape inference has been addressed in the latest versions of TensorFlow. Users are advised to upgrade to the patched versions to ensure their systems are secure. If you need further assistance or support in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
TensorFlow is an open-source machine learning framework developed by Google. It provides a comprehensive ecosystem for building and deploying machine learning models.
ReverseSequence is an operation in TensorFlow that allows reversing the elements of a tensor along a specified dimension.
The vulnerability can result in a heap out-of-bounds read, potentially leading to information disclosure or a crash.
To fix the vulnerability, users should upgrade to the patched versions of TensorFlow (2.8.0, 2.7.1, 2.6.3, or 2.5.3) depending on the currently installed version.
Yes, users can enforce a non-negative value for the batch_dim parameter passed to ReverseSequence to mitigate the vulnerability.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.