CVE-2022-35982: TensorFlow vulnerable to segfault in SparseBincount

tensorflow Updated 02 Oct 2025

Summary

16/09/2022
Yes i
Moderate
5.9

CVE-2022-35982: TensorFlow vulnerable to segfault in SparseBincount. 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

The same CVE-2022-35982 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 developed by Google. It provides a comprehensive ecosystem of tools, libraries, and resources for building and deploying machine learning models. TensorFlow is widely used in various domains, including research, industry, and academia. However, a vulnerability has been discovered in TensorFlow that can lead to a denial of service attack.

Vulnerability Detail

The vulnerability, identified as CVE-2022-35982, affects the SparseBincount function in TensorFlow. When provided with invalid inputs for indices, values, and dense_shape, the function can result in a segmentation fault (segfault). This can be exploited by an attacker to trigger a denial of service attack against a TensorFlow application. The vulnerability has a CVSS score of 5.9, indicating a moderate severity level.

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.2 2.7.2
    pip install --upgrade "tensorflow==2.7.2"
  • >= 2.8.0, < 2.8.1 2.8.1
    pip install --upgrade "tensorflow==2.8.1"
  • >= 2.9.0, < 2.9.1 2.9.1
    pip 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

If immediate updating is not possible, users can implement a workaround by avoiding the usage of the SparseBincount function with invalid inputs. It is recommended to validate the inputs before passing them to the function to ensure they form a valid sparse tensor. Here is an example of how to validate the inputs:

import tensorflow as tf

def validate_sparse_inputs(indices, values, dense_shape):
    if not isinstance(indices, tf.Tensor) or not isinstance(values, tf.Tensor) or not isinstance(dense_shape, tf.Tensor):
        raise ValueError('Invalid inputs: indices, values, and dense_shape must be TensorFlow tensors.')
    if indices.dtype != tf.int64 or values.dtype != tf.int32 or dense_shape.dtype != tf.int64:
        raise ValueError('Invalid inputs: indices, values, and dense_shape must have the correct data types.')
    if indices.shape.rank != 1 or values.shape.rank != 1 or dense_shape.shape.rank != 1:
        raise ValueError('Invalid inputs: indices, values, and dense_shape must be 1-dimensional tensors.')

# Usage example
indices = ...
values = ...
dense_shape = ...
validate_sparse_inputs(indices, values, dense_shape)

Conclusion

In conclusion, TensorFlow is vulnerable to a segfault in the SparseBincount function, which can be exploited for a denial of service attack. Users are advised to update their TensorFlow installation to one of the patched versions and validate inputs to avoid the vulnerability. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tensorflow →

Share this vulnerability

FAQ

TensorFlow is an open-source machine learning framework developed by Google. It provides tools and resources for building and deploying machine learning models.

The vulnerability can be exploited to trigger a denial of service attack against a TensorFlow application.

To fix the vulnerability, update your TensorFlow installation to one of the patched versions: TensorFlow 2.7.2, TensorFlow 2.8.1, or TensorFlow 2.9.1.

Yes, you can implement a workaround by validating the inputs before using the SparseBincount function.

You can consult the TensorFlow security guide for more information on the security model and how to report issues.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow.

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.2 2.7.2
    pip install --upgrade "tensorflow==2.7.2"
  • >= 2.8.0, < 2.8.1 2.8.1
    pip install --upgrade "tensorflow==2.8.1"
  • >= 2.9.0, < 2.9.1 2.9.1
    pip 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 →

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