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

Reference binding to nullptr in map operations in TensorFlow

CVE-2021-37671

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 tf.raw_ops.Map* and tf.raw_ops.OrderedMap* operations. The implementation has a check in place to ensure that indices is in ascending order, but does not check that indices is not empty. We have patched the issue in GitHub commit 532f5c5a547126c634fefd43bbad1dc6417678ac. 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
532f5c5a5471

Prevent nullptr deref in validation of indexes in map ops.

https://github.com/tensorflow/tensorflowMihai MaruseacJul 30, 2021via ghsa
1 file changed · +9 6
  • tensorflow/core/kernels/map_stage_op.cc+9 6 modified
    @@ -210,25 +210,28 @@ class StagingMap : public ResourceBase {
                                        const OptionalTuple& tuple)
           TF_EXCLUSIVE_LOCKS_REQUIRED(mu_) {
         if (tuple[index].has_value()) {
    -      return Status(errors::InvalidArgument(
    +      return errors::InvalidArgument(
               "The tensor for index '", index, "' for key '", key.scalar<int64>()(),
    -          "' was already initialized '", dtypes_.size(), "'."));
    +          "' was already initialized '", dtypes_.size(), "'.");
         }
     
         return Status::OK();
       }
     
       // Check that the indices are strictly ordered
       Status check_index_ordering(const Tensor& indices) {
    +    if (indices.NumElements() == 0) {
    +      return errors::InvalidArgument("Indices are empty");
    +    }
    +
         auto findices = indices.flat<int>();
     
         for (std::size_t i = 0; i < findices.dimension(0) - 1; ++i) {
           if (findices(i) < findices(i + 1)) {
             continue;
           }
     
    -      return Status(
    -          errors::InvalidArgument("Indices are not strictly ordered"));
    +      return errors::InvalidArgument("Indices are not strictly ordered");
         }
     
         return Status::OK();
    @@ -238,10 +241,10 @@ class StagingMap : public ResourceBase {
       Status check_memory_limit(std::size_t bytes)
           TF_EXCLUSIVE_LOCKS_REQUIRED(mu_) {
         if (has_memory_limit() && bytes > memory_limit_) {
    -      return Status(errors::ResourceExhausted(
    +      return errors::ResourceExhausted(
               "Attempted to insert tensors with combined size of '", bytes,
               "' bytes into Staging Area with a memory limit of '", memory_limit_,
    -          "'."));
    +          "'.");
         }
     
         return Status::OK();
    

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.