CVE-2021-37667: Reference binding to nullptr in unicode encoding in TensorFlow
Summary
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
- tensorflow · Bitnami
- tensorflow-cpu · PyPI
- tensorflow-gpu · PyPI
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.
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 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.42.3.4pip install --upgrade "tensorflow==2.3.4" -
>= 2.4.0, < 2.4.32.4.3pip install --upgrade "tensorflow==2.4.3" -
>= 2.5.0, < 2.5.12.5.1pip 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 →
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.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.