CVE-2022-36004: TensorFlow Denial of Service Vulnerability in tf.random.gamma
Summary
CVE-2022-36004: TensorFlow vulnerable to CHECK fail in tf.random.gamma. Affects tensorflow across 3 version ranges.
< 2.7.2
>= 2.8.0, < 2.8.1
>= 2.9.0, < 2.9.1
Fixed in 2.7.2, 2.8.1 or 2.9.1, depending on the release line you run. How to fix ↓
Also tracked for
- tensorflow-cpu · PyPI
- tensorflow-gpu · PyPI
- tensorflow · Bitnami
The same CVE-2022-36004 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
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.
No signup required · Results in about 60 seconds
Background
TensorFlow is an open-source machine learning library developed by Google, widely used for building and training machine learning models. It provides a flexible ecosystem for deploying machine learning applications across various platforms. However, TensorFlow is susceptible to certain vulnerabilities, including a critical issue in the tf.random.gamma function that can lead to denial of service under specific conditions.
Vulnerability Detail
The vulnerability arises when the tf.random.gamma function is called with large input shapes and rates, leading to a CHECK fail. This failure can be exploited to trigger a denial of service attack, causing the application to become unresponsive. The issue is particularly concerning for applications that rely on TensorFlow for generating random numbers in a production environment, as it can disrupt service availability and affect user experience.
How To Fix
Latest published version: 2.21.0 as of 22 Oct 2026
pip install --upgrade "tensorflow==2.21.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.7.22.7.2pip install --upgrade "tensorflow==2.7.2" -
>= 2.8.0, < 2.8.12.8.1pip install --upgrade "tensorflow==2.8.1" -
>= 2.9.0, < 2.9.12.9.1pip install --upgrade "tensorflow==2.9.1"
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
As a temporary workaround, avoid using tf.random.gamma with large input shapes and rates until the package is updated. Here is an example of how to limit the input size:
import tensorflow as tf arg_0 = tf.random.uniform(shape=(2,), dtype=tf.int32, maxval=65536) arg_1 = tf.random.uniform(shape=(2, 2), dtype=tf.float64, maxval=None) arg_2 = tf.random.uniform(shape=(2, 2, 2), dtype=tf.float64, maxval=None) arg_3 = tf.float64 arg_4 = 48 arg_5 = 'None' tf.random.gamma(shape=arg_0, alpha=arg_1, beta=arg_2, dtype=arg_3, seed=arg_4, name=arg_5)
Conclusion
The CVE-2022-36004 vulnerability in TensorFlow's tf.random.gamma function poses a significant risk of denial of service. It is crucial to update to the latest patched version of TensorFlow to mitigate this risk. Additionally, using Vulert can help monitor your applications for vulnerabilities effectively.
See every vulnerability recorded for tensorflow →
FAQ
CVE-2022-36004 is a vulnerability in TensorFlow's tf.random.gamma function that can lead to a denial of service when large input shapes and rates are used.
Exploiting this vulnerability can cause your application to become unresponsive, affecting service availability and user experience.
TensorFlow versions prior to 2.10.0, including 2.9.0, 2.8.0, and 2.7.0, are affected by this vulnerability.
You can use Vulert, which monitors and alerts for open-source vulnerabilities in real-time. Visit Vulert Scanner to check if your application is affected without any signup.
As a temporary measure, avoid using tf.random.gamma with large input shapes and rates until you can update to a patched version.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.