VYPR
High severityNVD Advisory· Published Feb 4, 2022· Updated Apr 22, 2025

Integer overflow in Tensorflow

CVE-2022-23576

Description

Tensorflow is an Open Source Machine Learning Framework. The implementation of OpLevelCostEstimator::CalculateOutputSize is vulnerable to an integer overflow if an attacker can create an operation which would involve tensors with large enough number of elements. We can have a large enough number of dimensions in output_shape.dim() or just a small number of dimensions being large enough to cause an overflow in the multiplication. The fix will be included in TensorFlow 2.8.0. We will also cherrypick this commit on TensorFlow 2.7.1, TensorFlow 2.6.3, and TensorFlow 2.5.3, as these are also affected and still in supported range.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
tensorflowPyPI
< 2.5.32.5.3
tensorflowPyPI
>= 2.6.0, < 2.6.32.6.3
tensorflowPyPI
>= 2.7.0, < 2.7.12.7.1
tensorflow-cpuPyPI
< 2.5.32.5.3
tensorflow-cpuPyPI
>= 2.6.0, < 2.6.32.6.3
tensorflow-cpuPyPI
>= 2.7.0, < 2.7.12.7.1
tensorflow-gpuPyPI
< 2.5.32.5.3
tensorflow-gpuPyPI
>= 2.6.0, < 2.6.32.6.3
tensorflow-gpuPyPI
>= 2.7.0, < 2.7.12.7.1

Affected products

1

Patches

1
b9bd6cfd1c50

Prevent integer overflow in `OpLevelCostEstimator::CalculateOutputSize`.

https://github.com/tensorflow/tensorflowMihai MaruseacNov 9, 2021via ghsa
2 files changed · +10 1
  • tensorflow/core/grappler/costs/BUILD+1 0 modified
    @@ -340,6 +340,7 @@ cc_library(
             "//tensorflow/core:lib",
             "//tensorflow/core:protos_all_cc",
             "//tensorflow/core/grappler/clusters:utils",
    +        "//tensorflow/core/util:overflow",
         ] + tf_protos_grappler(),
     )
     
    
  • tensorflow/core/grappler/costs/op_level_cost_estimator.cc+9 1 modified
    @@ -27,6 +27,7 @@ limitations under the License.
     #include "tensorflow/core/grappler/costs/op_context.h"
     #include "tensorflow/core/grappler/costs/utils.h"
     #include "tensorflow/core/platform/errors.h"
    +#include "tensorflow/core/util/overflow.h"
     
     namespace tensorflow {
     namespace grappler {
    @@ -1607,7 +1608,14 @@ int64_t OpLevelCostEstimator::CalculateOutputSize(const OpInfo& op_info,
         auto output_shape = MaybeGetMinimumShape(original_output_shape, num_dims,
                                                  found_unknown_shapes);
         for (const auto& dim : output_shape.dim()) {
    -      output_size *= dim.size();
    +      int64_t new_output_size =
    +          MultiplyWithoutOverflow(output_size, dim.size());
    +      if (new_output_size < 0) {
    +        VLOG(1) << "Overflow encountered when estimating cost, multiplying "
    +                << output_size << " with " << dim.size();
    +        return -1;
    +      }
    +      output_size = new_output_size;
         }
         total_output_size += output_size;
         VLOG(1) << "Output Size: " << output_size
    

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.