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

Null pointer dereference in `MatrixDiagPartOp` in TensorFlow

CVE-2021-37643

Description

TensorFlow is an end-to-end open source platform for machine learning. If a user does not provide a valid padding value to tf.raw_ops.MatrixDiagPartOp, then the code triggers a null pointer dereference (if input is empty) or produces invalid behavior, ignoring all values after the first. The implementation reads the first value from a tensor buffer without first checking that the tensor has values to read from. We have patched the issue in GitHub commit 482da92095c4d48f8784b1f00dda4f81c28d2988. 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
482da92095c4

Ensure non-empty padding_value input to tf.raw_ops.MatrixDiagPartV2, if a padding_value is input

https://github.com/tensorflow/tensorflowLaura PakAug 2, 2021via ghsa
1 file changed · +4 1
  • tensorflow/core/kernels/linalg/matrix_diag_op.cc+4 1 modified
    @@ -89,7 +89,10 @@ class MatrixDiagPartOp : public OpKernel {
               upper_diag_index = diag_index.flat<int32>()(1);
             }
           }
    -      padding_value = context->input(2).flat<T>()(0);
    +      const Tensor& padding_in = context->input(2);
    +      OP_REQUIRES(context, padding_in.NumElements() == 1,
    +                  errors::InvalidArgument("Padding must be scalar."));
    +      padding_value = padding_in.flat<T>()(0);
         }
         const TensorShape& input_shape = input.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.