VYPR
Low severityNVD Advisory· Published May 14, 2021· Updated Aug 3, 2024

Type confusion during tensor casts lead to dereferencing null pointers

CVE-2021-29513

Description

TensorFlow is an end-to-end open source platform for machine learning. Calling TF operations with tensors of non-numeric types when the operations expect numeric tensors result in null pointer dereferences. The conversion from Python array to C++ array(https://github.com/tensorflow/tensorflow/blob/ff70c47a396ef1e3cb73c90513da4f5cb71bebba/tensorflow/python/lib/core/ndarray_tensor.cc#L113-L169) is vulnerable to a type confusion. The fix will be included in TensorFlow 2.5.0. We will also cherrypick this commit on TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3 and TensorFlow 2.1.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.1.42.1.4
tensorflowPyPI
>= 2.2.0, < 2.2.32.2.3
tensorflowPyPI
>= 2.3.0, < 2.3.32.3.3
tensorflowPyPI
>= 2.4.0, < 2.4.22.4.2
tensorflow-cpuPyPI
< 2.1.42.1.4
tensorflow-cpuPyPI
>= 2.2.0, < 2.2.32.2.3
tensorflow-cpuPyPI
>= 2.3.0, < 2.3.32.3.3
tensorflow-cpuPyPI
>= 2.4.0, < 2.4.22.4.2
tensorflow-gpuPyPI
< 2.1.42.1.4
tensorflow-gpuPyPI
>= 2.2.0, < 2.2.32.2.3
tensorflow-gpuPyPI
>= 2.3.0, < 2.3.32.3.3
tensorflow-gpuPyPI
>= 2.4.0, < 2.4.22.4.2

Affected products

1

Patches

1
030af767d357

Fix `tf.raw_ops.ResourceCountUpTo` null pointer dereference.

https://github.com/tensorflow/tensorflowAmit PatankarApr 13, 2021via ghsa
1 file changed · +8 0
  • tensorflow/python/lib/core/ndarray_tensor.cc+8 0 modified
    @@ -16,6 +16,7 @@ limitations under the License.
     #include "tensorflow/python/lib/core/ndarray_tensor.h"
     
     #include <cstring>
    +#include <optional>
     
     #include "tensorflow/c/eager/tfe_context_internal.h"
     #include "tensorflow/c/tf_tensor_internal.h"
    @@ -74,6 +75,13 @@ Status PyArrayDescr_to_TF_DataType(PyArray_Descr* descr,
       PyObject* key;
       PyObject* value;
       Py_ssize_t pos = 0;
    +
    +  // Return an error if the fields attribute is null.
    +  // Occurs with an improper conversion attempt to resource.
    +  if (descr->fields == nullptr) {
    +    return errors::Internal("Unexpected numpy data type");
    +  }
    +
       if (PyDict_Next(descr->fields, &pos, &key, &value)) {
         // In Python 3, the keys of numpy custom struct types are unicode, unlike
         // Python 2, where the keys are bytes.
    

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.