CVE-2022-21734: TensorFlow GPU - MapStage Key Tensor Vulnerability

tensorflow-gpu Updated 02 Oct 2025

Summary

03/02/2022
Yes i
Unrated
Not published

CVE-2022-21734: Tensorflow is an Open Source Machine Learning Framework. Affects tensorflow-gpu across 3 version ranges.

< 2.5.3 >= 2.6.0, < 2.6.3 < f57315566d7094f322b784947093406c2aea0d7d

Fixed in 2.5.3 or 2.6.3, depending on the release line you run. How to fix ↓

Also tracked for

The same CVE-2022-21734 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

TensorFlow is an open-source machine learning framework widely used for developing and training machine learning models. It provides a comprehensive set of tools and libraries for building and deploying machine learning applications. TensorFlow GPU is a variant of TensorFlow that leverages GPU acceleration for faster computation. It is commonly used in scenarios where large-scale data processing and complex model training are required.

Vulnerability Detail

The vulnerability identified as CVE-2022-21734 affects the MapStage implementation in TensorFlow GPU. When the key tensor used in MapStage is not a scalar, a CHECK-fail occurs, leading to a potential security issue. This vulnerability can be exploited by an attacker to cause a denial-of-service (DoS) attack or execute arbitrary code on the affected system. The vulnerability was introduced in version 0 of TensorFlow GPU and has been fixed in versions 2.5.3, 2.6.3, and 2.7.1. The fix will also be included in the upcoming TensorFlow 2.8.0 release.

How To Fix

Latest published version: 2.12.0 as of 22 Oct 2026

pip install --upgrade "tensorflow-gpu==2.12.0"

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 2.5.3 2.5.3
    pip install --upgrade "tensorflow-gpu==2.5.3"
  • >= 2.6.0, < 2.6.3 2.6.3
    pip install --upgrade "tensorflow-gpu==2.6.3"

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

If immediate updating is not possible, a temporary workaround is to ensure that the key tensor used in MapStage is always a scalar. This can be achieved by modifying the code to handle non-scalar key tensors appropriately. Here is an example of how to modify the code to enforce scalar key tensors:

import tensorflow as tf

# Original code
key_tensor = ...  # Non-scalar key tensor
map_stage = tf.data.experimental.MapStage(..., key_tensor=key_tensor, ...)

# Modified code
key_tensor = tf.reshape(key_tensor, [])  # Ensure key tensor is scalar
map_stage = tf.data.experimental.MapStage(..., key_tensor=key_tensor, ...)

By reshaping the key tensor to have an empty shape, it is forced to be a scalar, mitigating the vulnerability.

Conclusion

The vulnerability in TensorFlow GPU's MapStage implementation can have serious security implications, including the possibility of a denial-of-service attack or arbitrary code execution. It is crucial to update TensorFlow GPU to the fixed versions or apply the provided workaround to mitigate the risk. For further assistance or support in vulnerability remediation, please reach out to DevNack.com.

See every vulnerability recorded for tensorflow-gpu →

Share this vulnerability

FAQ

TensorFlow GPU is a variant of TensorFlow that utilizes GPU acceleration for faster computation. It is commonly used in scenarios where large-scale data processing and complex model training are required.

MapStage is a component in TensorFlow GPU that allows for parallel processing of data during training. It is used to apply a function to each element of a dataset in parallel, improving performance.

The vulnerability in MapStage can lead to a CHECK-fail if the key tensor used is not a scalar. This can result in a denial-of-service (DoS) attack or arbitrary code execution on the affected system.

The vulnerability was introduced in version 0 of TensorFlow GPU and affects versions up to 2.5.2. It has been fixed in versions 2.5.3, 2.6.3, and 2.7.1. The fix will also be included in the upcoming TensorFlow 2.8.0 release.

To fix the vulnerability, it is recommended to update TensorFlow GPU to version 2.5.3, 2.6.3, or 2.7.1. Alternatively, upgrading to the latest version, TensorFlow 2.8.0, will also address the issue.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow-gpu.

How To Fix

Latest published version: 2.12.0 as of 22 Oct 2026

pip install --upgrade "tensorflow-gpu==2.12.0"

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 2.5.3 2.5.3
    pip install --upgrade "tensorflow-gpu==2.5.3"
  • >= 2.6.0, < 2.6.3 2.6.3
    pip install --upgrade "tensorflow-gpu==2.6.3"

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback