CVE-2022-29198: Denial of Service Vulnerability in TensorFlow
Summary
CVE-2022-29198: Missing validation causes denial of service via SparseTensorToCSRSparseMatrix. Affects tensorflow across 3 version ranges.
< 2.6.4
>= 2.7.0, < 2.7.2
>= 2.8.0, < 2.8.1
Fixed in 2.6.4, 2.7.2 or 2.8.1, depending on the release line you run. How to fix ↓
Also tracked for
- tensorflow-cpu · PyPI
- tensorflow-gpu · PyPI
- tensorflow · Bitnami
The same CVE-2022-29198 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 supports various operations, including sparse tensor operations, which allow efficient handling of large and sparse datasets. However, a vulnerability has been identified in the SparseTensorToCSRSparseMatrix function of TensorFlow, which can lead to a denial of service attack.
Vulnerability Detail
The SparseTensorToCSRSparseMatrix function in TensorFlow does not properly validate input arguments, leading to a CHECK failure. An attacker can exploit this vulnerability by providing malicious input, causing the function to fail and resulting in a denial of service condition. The vulnerability arises from the lack of validation for the dense_shape and indices parameters, which are assumed to have specific dimensions but are not checked for compliance. This vulnerability has a CVSS score of 5.5, indicating a moderate 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.6.42.6.4pip install --upgrade "tensorflow==2.6.4" -
>= 2.7.0, < 2.7.22.7.2pip install --upgrade "tensorflow==2.7.2" -
>= 2.8.0, < 2.8.12.8.1pip install --upgrade "tensorflow==2.8.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 add manual validation checks for the dense_shape and indices parameters before calling the SparseTensorToCSRSparseMatrix function. Here is an example of how to perform the validation in Python:
import tensorflow as tf
indices = tf.constant(53, shape=[3], dtype=tf.int64)
values = tf.constant(0.554979503, shape=[218650], dtype=tf.float32)
dense_shape = tf.constant(53, shape=[3], dtype=tf.int64)
if len(dense_shape.shape) != 1 or len(indices.shape) != 2:
raise ValueError("Invalid dimensions for dense_shape or indices")
# Call the function with validated inputs
result = tf.raw_ops.SparseTensorToCSRSparseMatrix(
indices=indices,
values=values,
dense_shape=dense_shape)
Conclusion
The vulnerability in TensorFlow's SparseTensorToCSRSparseMatrix function can be exploited to cause a denial of service condition. It is recommended to update to the patched versions of TensorFlow (2.6.4, 2.7.2, or 2.8.1) to mitigate this vulnerability. Users can also implement a manual validation check as a workaround. For further support on 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 of tools, libraries, and resources for building and deploying machine learning models.
SparseTensorToCSRSparseMatrix is a function in TensorFlow that converts a sparse tensor to a compressed sparse row (CSR) sparse matrix representation. This function is used for efficient storage and manipulation of large and sparse datasets.
A denial of service (DoS) attack is a type of cyber attack where an attacker aims to disrupt the normal functioning of a system or network by overwhelming it with a high volume of malicious requests or data. In the case of this vulnerability, an attacker can trigger a DoS condition by exploiting the lack of input validation in the SparseTensorToCSRSparseMatrix function.
The CVSS score of this vulnerability is 5.5, indicating a moderate severity level. CVSS (Common Vulnerability Scoring System) is a standardized system for assessing the severity and impact of security vulnerabilities.
To fix this vulnerability, you should update your TensorFlow installation to one of the patched versions (2.6.4, 2.7.2, or 2.8.1). This can be done by running the command pip install --upgrade tensorflow. It is recommended to always use the latest stable version of TensorFlow to ensure the latest security fixes and improvements.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.