CVE-2022-29208: TensorFlow - Segfault and OOB Write in EditDistance

tensorflow Updated 02 Oct 2025

Summary

24/05/2022
Yes i
High
7.1

CVE-2022-29208: Segfault and OOB write due to incomplete validation in EditDistance in TensorFlow. Affects tensorflow across 3 version ranges.

< 2.6.4 >= 2.7.0, < 2.7.2 >= 2.8.0, < 2.8.1

Fixed in 2.6.4, 2.7.2 or 2.8.1, depending on the release line you run. How to fix ↓

Also tracked for

The same CVE-2022-29208 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 Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

TensorFlow is an open-source machine learning framework widely used for building and training various deep learning models. It provides a comprehensive ecosystem of tools, libraries, and resources for developing and deploying machine learning applications. TensorFlow includes the tf.raw_ops.EditDistance function, which calculates the edit distance between two sequences. This function is vulnerable to a segmentation fault and out-of-bounds write due to incomplete validation.

Vulnerability Detail

The implementation of tf.raw_ops.EditDistance in TensorFlow lacks proper validation. By passing negative values as input, an attacker can trigger a segmentation fault, leading to a denial-of-service condition. The vulnerability arises from inadequate bounds checking when computing an index for a write operation. This allows an attacker to write before the array by manipulating the input to generate negative values for the index. The impact of this vulnerability can result in crashes, service interruptions, or potential exploitation for further attacks.

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.6.4 2.6.4
    pip install --upgrade "tensorflow==2.6.4"
  • >= 2.7.0, < 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"

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 workaround, users can ensure that only valid and non-negative values are passed as input to the tf.raw_ops.EditDistance function. It is crucial to validate and sanitize user input to prevent the exploitation of this vulnerability. Here is an example of how to validate the input in Python:

import tensorflow as tf

hypothesis_indices = tf.constant([[0, 1, 2], [3, 4, 5]], dtype=tf.int64)
# ... (other input tensors)

# Validate input
if tf.reduce_any(hypothesis_indices < 0):
    raise ValueError('Invalid input: hypothesis_indices contains negative values.')

# Call the patched EditDistance function
result = tf.raw_ops.EditDistance(
    hypothesis_indices=hypothesis_indices,
    # ... (other input tensors)
)

By performing this input validation, the vulnerability can be mitigated.

Conclusion

The vulnerability in TensorFlow's tf.raw_ops.EditDistance function has been addressed in the latest patched versions. Users are advised to update their TensorFlow installation to one of the fixed versions to mitigate the risk. It is important to regularly update software dependencies to ensure the security and stability of machine learning applications. For further support and assistance in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tensorflow →

Share this vulnerability

FAQ

TensorFlow is an open-source machine learning framework used for building and training deep learning models. It provides a wide range of tools and resources for developing machine learning applications.

The vulnerability in TensorFlow's tf.raw_ops.EditDistance function can lead to a segmentation fault and denial-of-service condition. It may result in crashes, service interruptions, or potential exploitation for further attacks.

To fix this vulnerability, update your TensorFlow installation to one of the patched versions: TensorFlow 2.6.4, TensorFlow 2.7.2, TensorFlow 2.8.1, or TensorFlow 2.9.0 (upcoming release). It is recommended to use the latest stable release.

Yes, you can validate and sanitize the input to the tf.raw_ops.EditDistance function to prevent the exploitation of this vulnerability. Ensure that only valid and non-negative values are passed as input.

This vulnerability was reported by Neophytos Christou from Secure Systems Lab at Brown University.

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.6.4 2.6.4
    pip install --upgrade "tensorflow==2.6.4"
  • >= 2.7.0, < 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"

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