CVE-2023-25665: TensorFlow Null Pointer Error in SparseSparseMaximum
Summary
CVE-2023-25665: TensorFlow has Null Pointer Error in SparseSparseMaximum. Affects tensorflow versions < 2.11.1. Fixed in 2.11.1. How to fix ↓
Also tracked for
- tensorflow-cpu · PyPI
- tensorflow-gpu · PyPI
- tensorflow · Bitnami
The same CVE-2023-25665 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 and functions for manipulating tensors, including sparse tensors. Sparse tensors are used to efficiently represent and process data with a large number of zero values. However, a vulnerability has been discovered in the SparseSparseMaximum operation of TensorFlow, which can lead to a Null Pointer Error (NPE) when given invalid sparse tensors as inputs.
Vulnerability Detail
The vulnerability in TensorFlow's SparseSparseMaximum operation arises when it receives invalid sparse tensors as inputs. This can trigger a Null Pointer Error, causing the program to crash or behave unexpectedly. An example code snippet demonstrating the vulnerability is as follows:
import tensorflow as tf
tf.raw_ops.SparseSparseMaximum(
a_indices=[[1]],
a_values=[0.1],
a_shape=[2],
b_indices=[[]],
b_values=[2],
b_shape=[2],
)
The impact of this vulnerability can vary depending on the context in which TensorFlow is used. In certain scenarios, an attacker may be able to exploit this vulnerability to cause a denial of service (DoS) attack or execute arbitrary code.
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 version below is the minimum fixed release for this vulnerability.
If you need the minimum change
2.11.1
This is the first release that contains the fix.
pip install --upgrade "tensorflow==2.11.1"
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
As a workaround, users can validate the inputs to the SparseSparseMaximum operation before invoking it. This can be done by checking the validity of the sparse tensors' indices, values, and shapes. Here is an example code snippet demonstrating the workaround:
import tensorflow as tf
def validate_sparse_tensors(a_indices, a_values, a_shape, b_indices, b_values, b_shape):
if len(a_indices) == 0 or len(b_indices) == 0:
raise ValueError('Invalid sparse tensor indices')
if len(a_values) == 0 or len(b_values) == 0:
raise ValueError('Invalid sparse tensor values')
if len(a_shape) != len(b_shape):
raise ValueError('Incompatible sparse tensor shapes')
validate_sparse_tensors([[1]], [0.1], [2], [[]], [2], [2])
# Invoke SparseSparseMaximum operation
# ...
By validating the inputs, users can ensure that only valid sparse tensors are passed to the SparseSparseMaximum operation, thereby avoiding the Null Pointer Error.
Conclusion
In conclusion, TensorFlow versions prior to 2.11.1 are vulnerable to a Null Pointer Error in the SparseSparseMaximum operation. This vulnerability can be mitigated by updating TensorFlow to the patched versions (2.12 or 2.11.1). Additionally, users can validate the inputs to the SparseSparseMaximum operation 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.
A sparse tensor is a data structure used in TensorFlow to efficiently represent and process data with a large number of zero values. It only stores the non-zero values along with their indices and shape.
The SparseSparseMaximum operation in TensorFlow is used to compute the element-wise maximum of two sparse tensors. It takes two sparse tensors as inputs and returns a new sparse tensor with the maximum values at each position.
A Null Pointer Error (NPE) is a runtime error that occurs when a program tries to access or dereference a null pointer, which points to no memory address. This can lead to program crashes or unexpected behavior.
To update TensorFlow to the patched version, you can use the package manager or follow the installation instructions provided by TensorFlow. Make sure to upgrade to TensorFlow 2.12 or TensorFlow 2.11.1, which include the fix for the vulnerability.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.