Advisory Database
  • Advisories
  • Dependency Scanning
  1. pypi
  2. ›
  3. tensorflow-cpu
  4. ›
  5. CVE-2021-41220

CVE-2021-41220: Use after free / memory leak in `CollectiveReduceV2`

November 10, 2021 (updated November 7, 2024)

The async implementation of CollectiveReduceV2 suffers from a memory leak and a use after free:

import tensorflow as tf

tf.raw_ops.CollectiveReduceV2(
input=[],
group_size=[-10, -10, -10],
group_key=[-10, -10],
instance_key=[-10],
ordering_token=[],
merge_op='Mul',
final_op='Div')

This occurs due to the asynchronous computation and the fact that objects that have been std::move()d from are still accessed:

auto done_with_cleanup = [col_params, done = std::move(done)]() {
done();
col_params->Unref();
};
OP_REQUIRES_OK_ASYNC(c,
FillCollectiveParams(col_params, REDUCTION_COLLECTIVE,
/*group_size*/ c->input(1),
/*group_key*/ c->input(2),
/*instance_key*/ c->input(3)),
done);

Here, done is already moved from by the time OP_REQUIRES_OK_ASYNC macro needs to invoke it in case of errors. In this case, we get an undefined behavior, which can manifest via crashes, std::bad_alloc throws or just memory leaks.

References

  • github.com/advisories/GHSA-gpfh-jvf9-7wg5
  • github.com/pypa/advisory-database/tree/main/vulns/tensorflow-cpu/PYSEC-2021-629.yaml
  • github.com/pypa/advisory-database/tree/main/vulns/tensorflow-gpu/PYSEC-2021-827.yaml
  • github.com/pypa/advisory-database/tree/main/vulns/tensorflow/PYSEC-2021-412.yaml
  • github.com/tensorflow/tensorflow
  • github.com/tensorflow/tensorflow/commit/ca38dab9d3ee66c5de06f11af9a4b1200da5ef75
  • github.com/tensorflow/tensorflow/security/advisories/GHSA-gpfh-jvf9-7wg5
  • nvd.nist.gov/vuln/detail/CVE-2021-41220

Code Behaviors & Features

Detect and mitigate CVE-2021-41220 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Dependency Scanning using SBOM also detects vulnerabilities from proprietary advisories that this site does not include. Learn more about Dependency Scanning using SBOM →

Affected versions

All versions starting from 2.6.0 before 2.6.1, version 2.6.0

Fixed versions

  • 2.6.1

Solution

Upgrade to version 2.6.1 or above.

Impact 7.8 HIGH

CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Learn more about CVSS

Weakness

  • CWE-416: Use After Free

Source file

pypi/tensorflow-cpu/CVE-2021-41220.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Sun, 08 Nov 2026 00:15:51 +0000.