CVE-2022-21728: Out of Bounds Read in Tensorflow
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 · Bitnami
- 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 of tools, libraries, and resources for building and deploying machine learning models. Tensorflow is widely used in various domains, including research, industry, and academia. However, a vulnerability has been discovered in Tensorflow that could potentially lead to an out of bounds read.
Vulnerability Detail
The vulnerability in Tensorflow is related to the implementation of shape inference for the ReverseSequence operation. The code does not properly validate the value of the batch_dim parameter, which can result in a heap out of bounds read. An attacker could exploit this vulnerability to read sensitive information from the heap, potentially leading to information disclosure or other security issues. The vulnerability has a CVSS score of 8.1, indicating a high severity level.
How To Fix
Latest published version: 2.21.0 as of 22 Oct 2026
pip install --upgrade "tensorflow==2.21.0"
Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.
If you can't move to the latest
The minimum fixed version depends on the release line you run.
-
< 2.5.32.5.3pip install --upgrade "tensorflow==2.5.3" -
>= 2.6.0, < 2.6.32.6.3pip install --upgrade "tensorflow==2.6.3" -
>= 2.7.0, < 2.7.12.7.1pip install --upgrade "tensorflow==2.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 temporary workaround, you can avoid using the ReverseSequence operation with negative values for the seq_dim and batch_dim parameters. Make sure to validate and sanitize user input to prevent any potential exploitation of this vulnerability. Here is an example of how to modify the code to avoid the vulnerability:
import tensorflow as tf
@tf.function
def test():
y = tf.raw_ops.ReverseSequence(
input=['aaa', 'bbb'],
seq_lengths=[1, 1, 1],
seq_dim=0, # Modify the value of seq_dim
batch_dim=0 # Modify the value of batch_dim
)
return y
test()
Conclusion
In conclusion, the vulnerability in Tensorflow could lead to an out of bounds read, potentially resulting in information disclosure or other security issues. It is crucial to update to the latest patched version of Tensorflow to mitigate the risk. If you are unable to update immediately, consider implementing the provided workaround and ensure proper input validation and sanitization. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
The vulnerability could allow an attacker to read sensitive information from the heap, potentially leading to information disclosure or other security issues.
To fix this vulnerability, you should update to the latest patched version of Tensorflow. Refer to the vulnerability details for the specific versions that include the fix.
Yes, you can avoid using the ReverseSequence operation with negative values for the seq_dim and batch_dim parameters as a temporary workaround. Make sure to validate and sanitize user input to prevent any potential exploitation of this vulnerability.
Yes, the CVSS score for this vulnerability is 8.1, indicating a high severity level.
You can find more information about this vulnerability in the provided vulnerability details. Additionally, you can refer to the Tensorflow security guide for general information about the security model and how to contact the Tensorflow team with any issues or questions.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.