VYPR
Moderate severityNVD Advisory· Published Nov 5, 2021· Updated Aug 4, 2024

Heap buffer overflow in `Transpose`

CVE-2021-41216

Description

TensorFlow is an open source platform for machine learning. In affected versions the shape inference function for Transpose is vulnerable to a heap buffer overflow. This occurs whenever perm contains negative elements. The shape inference function does not validate that the indices in perm are all valid. The fix will be included in TensorFlow 2.7.0. We will also cherrypick this commit on TensorFlow 2.6.1, TensorFlow 2.5.2, and TensorFlow 2.4.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.6.0, < 2.6.12.6.1
tensorflowPyPI
>= 2.5.0, < 2.5.22.5.2
tensorflowPyPI
< 2.4.42.4.4
tensorflow-cpuPyPI
>= 2.6.0, < 2.6.12.6.1
tensorflow-cpuPyPI
>= 2.5.0, < 2.5.22.5.2
tensorflow-cpuPyPI
< 2.4.42.4.4
tensorflow-gpuPyPI
>= 2.6.0, < 2.6.12.6.1
tensorflow-gpuPyPI
>= 2.5.0, < 2.5.22.5.2
tensorflow-gpuPyPI
< 2.4.42.4.4

Affected products

1

Patches

1
c79ba87153ee

Make Transpose's shape inference function validate that negative `perm` values are within the tensor's rank.

https://github.com/tensorflow/tensorflowPenporn KoanantakoolOct 15, 2021via ghsa
1 file changed · +1 1
  • tensorflow/core/ops/array_ops.cc+1 1 modified
    @@ -168,7 +168,7 @@ Status TransposeShapeFn(InferenceContext* c) {
     
         for (int32_t i = 0; i < rank; ++i) {
           int64_t in_idx = data[i];
    -      if (in_idx >= rank) {
    +      if (in_idx >= rank || in_idx <= -rank) {
             return errors::InvalidArgument("perm dim ", in_idx,
                                            " is out of range of input rank ", rank);
           }
    

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

8

News mentions

0

No linked articles in our index yet.