🛡️ CVE-2021-29531 — tensorflow

🟡 CVSS 5.0 — Medium ✅ No Known Exploit OSV
5.0
CVSS Score
0 Low4 Medium7 High9 Critical10

Description

CHECK-fail in tf.raw_ops.EncodePng

TensorFlow is an end-to-end open source platform for machine learning. An attacker can trigger a CHECK fail in PNG encoding by providing an empty input tensor as the pixel data. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/e312e0791ce486a80c9d23110841525c6f7c3289/tensorflow/core/kernels/image/encode_png_op.cc#L57-L60) only validates that the total number of pixels in the image does not overflow. Thus, an attacker can send an empty matrix for encoding. However, if the tensor is empty, then the associated buffer is nullptr. Hence, when calling png::WriteImageToBuffer(https://github.com/tensorflow/tensorflow/blob/e312e0791ce486a80c9d23110841525c6f7c3289/tensorflow/core/kernels/image/encode_png_op.cc#L79-L93), the first argument (i.e., image.flat<T>().data()) is NULL. This then triggers the CHECK_NOTNULL in the first line of png::WriteImageToBuffer(https://github.com/tensorflow/tensorflow/blob/e312e0791ce486a80c9d23110841525c6f7c3289/tensorflow/core/lib/png/png_io.cc#L345-L349). Since image is null, this results in abort being called after printing the stacktrace. Effectively, this allows an attacker to mount a denial of service attack. The fix will be included in TensorFlow 2.5.0. We will also cherrypick this commit on TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3 and TensorFlow 2.1.4, as these are also affected and still in supported range.

Affected software

CVE-2021-29531 is recorded against 1 package.

  • tensorflow

Timeline and source

Published on 6 March 2024 and last revised on 20 May 2025. No public exploit is currently recorded for this entry. Record sourced from OSV.

References

github.com (Web)
github.com (Web)
nvd.nist.gov (Web)

Details

Severity MEDIUM
CVSS Score 5.0
CVSS Vector N/A
CWE N/A
Public Exploit ✅ No
Source OSV
Published 2024-03-06
Updated 2026-08-12
Modified 2025-05-20
Fix URL N/A

Affected Packages

Software From version Fixed in
tensorflow

Similar Threats

Vulnerability Monitoring

Track new vulnerabilities in tensorflow

CVE-2021-29531 is rated CVSS 5.0 Medium. BotEraser monitors your WordPress installation and notifies you when software you use appears in our vulnerability database.

Set Up Free Alerts →

No credit card required  ·  Results in minutes

ⓘ Data Notice: The information presented above has been compiled from publicly available internet sources. Boteraser aggregates this data solely for informational purposes and does not independently classify, evaluate, or endorse any findings about the vulnerabilities listed. The accuracy and completeness of this information is the sole responsibility of the original publishers. Boteraser and its operators accept no liability for any decisions made based on this data.