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

Null dereference in Grappler's `TrySimplify`

CVE-2021-29616

Description

TensorFlow is an end-to-end open source platform for machine learning. The implementation of TrySimplify(https://github.com/tensorflow/tensorflow/blob/c22d88d6ff33031aa113e48aa3fc9aa74ed79595/tensorflow/core/grappler/optimizers/arithmetic_optimizer.cc#L390-L401) has undefined behavior due to dereferencing a null pointer in corner cases that result in optimizing a node with no inputs. 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
e6340f0665d5

Handle a special grappler case resulting in crash.

https://github.com/tensorflow/tensorflowMihai MaruseacApr 19, 2021via ghsa
2 files changed · +17 0
  • tensorflow/core/grappler/optimizers/arithmetic_optimizer.cc+11 0 modified
    @@ -2047,6 +2047,12 @@ class ReorderCastLikeAndValuePreserving : public ArithmeticOptimizerStage {
     
       Status TrySimplify(NodeDef* consumer, string* simplified_node_name) override {
         NodeDef* producer;
    +
    +    if (consumer->input_size() < 1) {
    +      return errors::FailedPrecondition("Node ", simplified_node_name,
    +                                        " lacks inputs");
    +    }
    +
         TF_RETURN_IF_ERROR(GetInputNode(consumer->input(0), &producer));
         const bool producer_is_cast = IsCastLike(*producer);
         const bool can_optimize =
    @@ -2538,6 +2544,11 @@ class ReplaceMulWithSquare : public ArithmeticOptimizerStage {
       ~ReplaceMulWithSquare() override = default;
     
       bool IsSupported(const NodeDef* node) const override {
    +    if (!node || node->input_size() < 2) {
    +      // Invalid node
    +      return false;
    +    }
    +
         return IsAnyMul(*node) && node->input(0) == node->input(1);
       }
     
    
  • tensorflow/core/grappler/optimizers/dependency_optimizer.cc+6 0 modified
    @@ -68,6 +68,12 @@ bool DependencyOptimizer::SafeToRemoveIdentity(const NodeDef& node) const {
         // The output values of this node may be needed.
         return false;
       }
    +
    +  if (node.input_size() < 1) {
    +    // Node lacks input, is invalid
    +    return false;
    +  }
    +
       const NodeDef* input = node_map_->GetNode(NodeName(node.input(0)));
       CHECK(input != nullptr) << "node = " << node.name()
                               << " input = " << node.input(0);
    

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.