VYPR
Moderate severityNVD Advisory· Published Nov 18, 2022· Updated Apr 22, 2025

`CHECK_EQ` fail via input in `SparseMatrixNNZ` in Tensorflow

CVE-2022-41901

Description

TensorFlow is an open source platform for machine learning. An input sparse_matrix that is not a matrix with a shape with rank 0 will trigger a CHECK fail in tf.raw_ops.SparseMatrixNNZ. We have patched the issue in GitHub commit f856d02e5322821aad155dad9b3acab1e9f5d693. The fix will be included in TensorFlow 2.11. We will also cherrypick this commit on TensorFlow 2.10.1, 2.9.3, and TensorFlow 2.8.4, as these are also affected and still in supported range.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
tensorflowPyPI
< 2.8.42.8.4
tensorflowPyPI
>= 2.9.0, < 2.9.32.9.3
tensorflowPyPI
>= 2.10.0, < 2.10.12.10.1
tensorflow-cpuPyPI
< 2.8.42.8.4
tensorflow-gpuPyPI
< 2.8.42.8.4
tensorflow-cpuPyPI
>= 2.9.0, < 2.9.32.9.3
tensorflow-gpuPyPI
>= 2.9.0, < 2.9.32.9.3
tensorflow-cpuPyPI
>= 2.10.0, < 2.10.12.10.1
tensorflow-gpuPyPI
>= 2.10.0, < 2.10.12.10.1

Affected products

1

Patches

1
f856d02e5322

Fix missing sparse matrix crash.

https://github.com/tensorflow/tensorflowAntonio SanchezSep 23, 2022via ghsa
2 files changed · +17 0
  • tensorflow/core/kernels/sparse/sparse_matrix.h+7 0 modified
    @@ -25,10 +25,12 @@ limitations under the License.
     #include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
     #include "tensorflow/core/framework/op_kernel.h"
     #include "tensorflow/core/framework/tensor.h"
    +#include "tensorflow/core/framework/tensor_shape.h"
     #include "tensorflow/core/framework/tensor_types.h"
     #include "tensorflow/core/framework/variant.h"
     #include "tensorflow/core/framework/variant_encode_decode.h"
     #include "tensorflow/core/framework/variant_op_registry.h"
    +#include "tensorflow/core/platform/errors.h"
     
     namespace tensorflow {
     
    @@ -633,6 +635,11 @@ template <typename T>
     Status ExtractVariantFromInput(OpKernelContext* ctx, int index,
                                    const T** value) {
       const Tensor& input_t = ctx->input(index);
    +  if (!TensorShapeUtils::IsScalar(input_t.shape())) {
    +    return errors::InvalidArgument(
    +        "Invalid input matrix: Shape must be rank 0 but is rank ",
    +        input_t.dims());
    +  }
       const Variant& input_variant = input_t.scalar<Variant>()();
       *value = input_variant.get<T>();
       if (*value == nullptr) {
    
  • tensorflow/python/kernel_tests/linalg/sparse/csr_sparse_matrix_ops_test.py+10 0 modified
    @@ -1313,6 +1313,16 @@ def testOrderingAMD(self):
           self.assertLess(cholesky_with_amd_nnz_value,
                           cholesky_without_ordering_nnz_value)
     
    +  @test_util.run_in_graph_and_eager_modes
    +  def testNoMatrixNoCrash(self):
    +    # Round-about way of creating an empty variant tensor that works in both
    +    # graph and eager modes.
    +    no_matrix = array_ops.reshape(dense_to_csr_sparse_matrix([[0.0]]), [1])[0:0]
    +    with self.assertRaisesRegex(
    +        (ValueError, errors.InvalidArgumentError),
    +        "(Invalid input matrix)|(Shape must be rank 0)"):
    +      sparse_csr_matrix_ops.sparse_matrix_nnz(no_matrix)
    +
     
     class CSRSparseMatrixOpsBenchmark(test.Benchmark):
     
    

Vulnerability mechanics

Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

5

News mentions

0

No linked articles in our index yet.