CVE-2022-23585: Memory Leak in TensorFlow when Decoding PNG Images

tensorflow-cpu Updated 02 Oct 2025

Summary

04/02/2022
Yes i
Unrated
Not published

CVE-2022-23585: Tensorflow is an Open Source Machine Learning Framework. Affects tensorflow-cpu across 3 version ranges.

< 2.5.3 >= 2.6.0, < 2.6.3 < ab51e5b813573dc9f51efa335aebcf2994125ee9

Fixed in 2.5.3 or 2.6.3, 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

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

TensorFlow is an open-source machine learning framework widely used for developing and training machine learning models. It provides a comprehensive set of tools and libraries for building and deploying machine learning applications. TensorFlow supports various image formats, including PNG, for image processing tasks. However, a vulnerability has been identified in TensorFlow that can lead to a memory leak when decoding PNG images.

Vulnerability Detail

The vulnerability arises during the decoding process of PNG images in TensorFlow. When an invalid image is encountered, TensorFlow can produce a memory leak due to improper handling of allocated buffers. Specifically, after calling the png::CommonInitDecode(..., &decode) function, the decode value contains allocated buffers that can only be freed by calling png::CommonFreeDecode(&decode). However, certain error cases in the function implementation invoke the OP_REQUIRES macro, which abruptly terminates the execution of the function without allowing for the memory free operation. This results in a memory leak. The vulnerability can have significant ramifications, including potential denial-of-service (DoS) attacks and resource exhaustion.

How To Fix

Latest published version: 2.21.0 as of 22 Oct 2026

pip install --upgrade "tensorflow-cpu==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.5.3 2.5.3
    pip install --upgrade "tensorflow-cpu==2.5.3"
  • >= 2.6.0, < 2.6.3 2.6.3
    pip install --upgrade "tensorflow-cpu==2.6.3"

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 temporary workaround, users can manually free the allocated buffers by calling png::CommonFreeDecode(&decode) in the error handling code paths. This ensures that the memory is properly released even in cases where the function execution is terminated prematurely. Here is an example of how the workaround can be implemented in Python:

import tensorflow as tf

# Decoding PNG image
image_data = ...  # PNG image data

decode = tf.png.decode_png(image_data)

try:
    # Perform image processing
    ...
except Exception as e:
    # Handle error and free allocated buffers
    tf.png.CommonFreeDecode(decode)
    raise e

Conclusion

In conclusion, TensorFlow is susceptible to a memory leak vulnerability when decoding PNG images. This vulnerability can lead to resource exhaustion and potential denial-of-service attacks. The TensorFlow development team has addressed the issue in the upcoming release of TensorFlow 2.8.0 and has backported the fix to earlier versions. Users are strongly advised to upgrade their TensorFlow installations to the latest patched version to mitigate the vulnerability. For further support and assistance with vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tensorflow-cpu →

Share this vulnerability

FAQ

TensorFlow is an open-source machine learning framework used for developing and training machine learning models. It provides a comprehensive set of tools and libraries for building and deploying machine learning applications.

The vulnerability can result in a memory leak when decoding PNG images in TensorFlow. This can lead to resource exhaustion and potential denial-of-service (DoS) attacks.

The vulnerability affects TensorFlow versions 2.5.3, 2.6.3, and 2.7.1. However, the upcoming release of TensorFlow 2.8.0 will include the fix.

To fix this vulnerability, users should upgrade their TensorFlow installations to the latest patched version, which includes the fix. Specifically, upgrading to TensorFlow 2.8.0 or any of the backported versions (2.7.1, 2.6.3, or 2.5.3) will mitigate the vulnerability.

Yes, a temporary workaround is available. Users can manually free the allocated buffers by calling png::CommonFreeDecode(&decode) in the error handling code paths. However, it is recommended to upgrade to the patched version as soon as possible.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow-cpu.

How To Fix

Latest published version: 2.21.0 as of 22 Oct 2026

pip install --upgrade "tensorflow-cpu==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.5.3 2.5.3
    pip install --upgrade "tensorflow-cpu==2.5.3"
  • >= 2.6.0, < 2.6.3 2.6.3
    pip install --upgrade "tensorflow-cpu==2.6.3"

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