CVE-2021-29518: TensorFlow - Null Pointer Dereference in Eager Mode

tensorflow Updated 02 Oct 2025

Summary

06/03/2024
Yes i
High
Not published

CVE-2021-29518: Session operations in eager mode lead to null pointer dereferences. Affects tensorflow across 4 version ranges.

< 2.1.4 >= 2.2.0, < 2.2.3 >= 2.3.0, < 2.3.3 >= 2.4.0, < 2.4.2

Fixed in 4 releases; the minimum fixed version depends on the release line you run. How to fix ↓

Also tracked for

The same CVE-2021-29518 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 MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

TensorFlow is an end-to-end open source platform for machine learning. It provides a comprehensive ecosystem of tools, libraries, and resources for developing and deploying machine learning models. TensorFlow supports eager mode, which allows for immediate execution of operations, and session mode, which provides a more traditional graph-based execution model. In eager mode, session operations are invalid, but users can still call the raw ops associated with them. This vulnerability arises from a null pointer dereference in the implementation of session operations in eager mode.

Vulnerability Detail

In TensorFlow's eager mode, the session state pointer is dereferenced without checking if it is valid. This can lead to a null pointer dereference, causing undefined behavior. An attacker could exploit this vulnerability by triggering the execution of session operations in eager mode, resulting in a crash or potential code execution. The vulnerability has been assigned the identifier CVE-2021-29518 and has a severity rating of High.

How To Fix

Fixed versions by release line

The minimum fixed version depends on the release line you run.

  • < 2.1.4 2.1.4
  • >= 2.2.0, < 2.2.3 2.2.3
  • >= 2.3.0, < 2.3.3 2.3.3
  • >= 2.4.0, < 2.4.2 2.4.2

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 using eager mode and switch to session mode for executing operations. By using session mode, the vulnerability can be bypassed. Here is an example of how to switch from eager mode to session mode:

import tensorflow as tf

# Disable eager execution
tf.compat.v1.disable_eager_execution()

# Rest of the code using session mode
...

By disabling eager execution, the vulnerable session operations will not be triggered, eliminating the risk of null pointer dereference.

Conclusion

In conclusion, TensorFlow is affected by a high-severity vulnerability that allows for a null pointer dereference in eager mode. This can be exploited to cause crashes or potentially execute arbitrary code. Users should update their TensorFlow installations to the latest patched version and consider switching from eager mode to session mode as a workaround. 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 platform for machine learning, providing tools and resources for developing and deploying machine learning models.

Eager mode in TensorFlow allows for immediate execution of operations, providing a more interactive and intuitive programming experience.

This vulnerability affects TensorFlow when used in eager mode. It allows for a null pointer dereference, which can lead to crashes or potential code execution.

This vulnerability has a severity rating of High.

To mitigate the risk, it is recommended to update TensorFlow to the latest patched version, which includes a fix for this vulnerability.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow.

How To Fix

Fixed versions by release line

The minimum fixed version depends on the release line you run.

  • < 2.1.4 2.1.4
  • >= 2.2.0, < 2.2.3 2.2.3
  • >= 2.3.0, < 2.3.3 2.3.3
  • >= 2.4.0, < 2.4.2 2.4.2

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