CVE-2022-23585: TensorFlow Memory Leak in PNG Image Decoding

tensorflow Updated 02 Oct 2025

Summary

06/03/2024
Yes i
Medium
Not published

CVE-2022-23585: Memory leak in decoding PNG images in Tensorflow. Affects tensorflow across 3 version ranges.

< 2.5.3 >= 2.6.0, < 2.6.3 >= 2.7.0, < 2.7.1

Fixed in 2.5.3, 2.6.3 or 2.7.1, depending on the release line you run. How to fix ↓

Also tracked for

The same CVE-2022-23585 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 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 image formats, including PNG. However, a vulnerability has been identified in TensorFlow's PNG image decoding functionality, which can lead to a memory leak if the image is invalid.

Vulnerability Detail

The vulnerability arises when decoding PNG images in TensorFlow. After calling the png::CommonInitDecode(..., &decode) function, allocated buffers are stored in the decode value. These buffers can only be freed by calling png::CommonFreeDecode(&decode). However, certain error cases in the function implementation invoke the OP_REQUIRES macro, which terminates the function execution without allowing for the memory free to occur. This results in a memory leak. The impact of this vulnerability can lead to increased memory usage and potential resource exhaustion.

How To Fix

Fixed versions by release line

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

  • < 2.5.3 2.5.3
  • >= 2.6.0, < 2.6.3 2.6.3
  • >= 2.7.0, < 2.7.1 2.7.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 implement a manual memory deallocation process by calling png::CommonFreeDecode(&decode) in error handling code paths. This ensures that the allocated buffers are freed even if the function execution is terminated prematurely. Here is an example of how the workaround can be implemented in Python:

import tensorflow as tf

# Decode PNG image
def decode_png(image):
    decode = tf.png.decode_png(image)
    try:
        # Process decoded image
        ...
    except Exception as e:
        # Handle error
        ...
        # Free allocated buffers
        tf.png.CommonFreeDecode(decode)
        raise e

# Usage
image_data = ...
decode_png(image_data)

Conclusion

In conclusion, the identified vulnerability in TensorFlow's PNG image decoding functionality can lead to a memory leak and potential resource exhaustion. It is crucial for users to update their TensorFlow installations to the fixed versions once they are released. Implementing the provided workaround can also help mitigate the risk. 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 a comprehensive ecosystem of tools, libraries, and resources for building and deploying machine learning models.

The vulnerability can result in a memory leak when decoding PNG images in TensorFlow. This can lead to increased memory usage and potential resource exhaustion.

The vulnerability affects TensorFlow versions 2.5.2, 2.6.0, 2.6.1, 2.6.2, and 2.7.0.

The vulnerability will be fixed in TensorFlow 2.8.0. Users are advised to update their TensorFlow installations to the fixed versions once they are released.

Yes, a workaround is available. Users can manually deallocate the allocated buffers by calling png::CommonFreeDecode(&decode) in error handling code paths.

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.5.3 2.5.3
  • >= 2.6.0, < 2.6.3 2.6.3
  • >= 2.7.0, < 2.7.1 2.7.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