CVE-2021-37667: Reference binding to nullptr in unicode encoding in TensorFlow

tensorflow Updated 02 Oct 2025

Summary

25/08/2021
Yes i
High
7.8

CVE-2021-37667: Reference binding to nullptr in unicode encoding. Affects tensorflow across 3 version ranges.

< 2.3.4 >= 2.4.0, < 2.4.3 >= 2.5.0, < 2.5.1

Fixed in 2.3.4, 2.4.3 or 2.5.1, depending on the release line you run. How to fix ↓

Also tracked for

The same CVE-2021-37667 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 developed by Google. It provides a comprehensive ecosystem of tools, libraries, and resources for building and deploying machine learning models. TensorFlow supports various programming languages, including Python, C++, and Java. This vulnerability affects the TensorFlow package and its related distributions, such as tensorflow-cpu and tensorflow-gpu.

Vulnerability Detail

The vulnerability, identified as CVE-2021-37667, allows an attacker to cause undefined behavior by binding a reference to a null pointer in the unicode encoding functionality of TensorFlow. Specifically, the issue lies in the tf.raw_ops.UnicodeEncode function. By exploiting this vulnerability, an attacker can trigger undefined behavior, potentially leading to a denial of service (DoS) or arbitrary code execution.

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.3.4 2.3.4
    pip install --upgrade "tensorflow==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip install --upgrade "tensorflow==2.4.3"
  • >= 2.5.0, < 2.5.1 2.5.1
    pip install --upgrade "tensorflow==2.5.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 avoid the vulnerable code path by not using the tf.raw_ops.UnicodeEncode function with null pointer references. Instead, they can validate the input tensors and ensure that the input_splits tensor is not empty before calling the function. Here's an example of how to perform the validation:

import tensorflow as tf
from tensorflow.python.ops import gen_string_ops

def unicode_encode_safe(input_values, input_splits, output_encoding='UTF-8', errors='ignore', replacement_char='a'):
  if input_splits.shape[0] == 0:
    raise ValueError('input_splits tensor cannot be empty')
  return gen_string_ops.unicode_encode(
    input_values=input_values,
    input_splits=input_splits,
    output_encoding=output_encoding,
    errors=errors,
    replacement_char=replacement_char
  )

unicode_encode_safe([], [], 'UTF-8', 'ignore', 'a')

By adding the validation check, users can ensure that the input_splits tensor is not empty before proceeding with the encoding operation.

Conclusion

In conclusion, the vulnerability CVE-2021-37667 in TensorFlow allows an attacker to cause undefined behavior by binding a reference to a null pointer in the unicode encoding functionality. The TensorFlow team has released patched versions to address this vulnerability, and users are advised to update their installations. By following the recommended steps, users can mitigate the risk of exploitation. For further support on vulnerability remediation, you can 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 allows an attacker to cause undefined behavior in TensorFlow, potentially leading to a denial of service or arbitrary code execution.

To fix the vulnerability, users should update their TensorFlow installation to one of the patched versions: TensorFlow 2.6.0, TensorFlow 2.5.1, TensorFlow 2.4.3, or TensorFlow 2.3.4.

Yes, users can avoid the vulnerable code path by validating the input tensors and ensuring that the input_splits tensor is not empty before calling the tf.raw_ops.UnicodeEncode function.

For more information, you can refer to the TensorFlow security guide and the GitHub advisory database.

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.3.4 2.3.4
    pip install --upgrade "tensorflow==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip install --upgrade "tensorflow==2.4.3"
  • >= 2.5.0, < 2.5.1 2.5.1
    pip install --upgrade "tensorflow==2.5.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