VYPR
Moderate severityNVD Advisory· Published Aug 12, 2021· Updated Aug 4, 2024

Reference binding to nullptr in `MatrixSetDiagV*` ops in TensorFlow

CVE-2021-37658

Description

TensorFlow is an end-to-end open source platform for machine learning. In affected versions an attacker can cause undefined behavior via binding a reference to null pointer in all operations of type tf.raw_ops.MatrixSetDiagV*. The implementation has incomplete validation that the value of k is a valid tensor. We have check that this value is either a scalar or a vector, but there is no check for the number of elements. If this is an empty tensor, then code that accesses the first element of the tensor is wrong. We have patched the issue in GitHub commit ff8894044dfae5568ecbf2ed514c1a37dc394f1b. The fix will be included in TensorFlow 2.6.0. We will also cherrypick this commit on TensorFlow 2.5.1, TensorFlow 2.4.3, and TensorFlow 2.3.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.3.42.3.4
tensorflowPyPI
>= 2.4.0, < 2.4.32.4.3
tensorflowPyPI
>= 2.5.0, < 2.5.12.5.1
tensorflow-cpuPyPI
< 2.3.42.3.4
tensorflow-cpuPyPI
>= 2.4.0, < 2.4.32.4.3
tensorflow-cpuPyPI
>= 2.5.0, < 2.5.12.5.1
tensorflow-gpuPyPI
< 2.3.42.3.4
tensorflow-gpuPyPI
>= 2.4.0, < 2.4.32.4.3
tensorflow-gpuPyPI
>= 2.5.0, < 2.5.12.5.1

Affected products

1

Patches

1
ff8894044dfa

Add one missing valdiation to `matrix_set_diag_op.cc`

https://github.com/tensorflow/tensorflowMihai MaruseacJul 31, 2021via ghsa
1 file changed · +3 0
  • tensorflow/core/kernels/linalg/matrix_set_diag_op.cc+3 0 modified
    @@ -70,6 +70,9 @@ class MatrixSetDiagOp : public OpKernel {
                       errors::InvalidArgument(
                           "diag_index must be a scalar or vector, received shape: ",
                           diag_index.shape().DebugString()));
    +      OP_REQUIRES(
    +          context, diag_index.NumElements() > 0,
    +          errors::InvalidArgument("diag_index must have at least one element"));
           lower_diag_index = diag_index.flat<int32>()(0);
           upper_diag_index = lower_diag_index;
           if (TensorShapeUtils::IsVector(diag_index.shape())) {
    

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

7

News mentions

0

No linked articles in our index yet.