CVE-2021-29515
Python vulnerability analysis and mitigation

Overview

TensorFlow's MatrixDiag* operations contained a vulnerability (CVE-2021-29515) discovered in May 2021. The vulnerability affected TensorFlow versions prior to 2.5.0, specifically impacting versions 2.1.x, 2.2.x, 2.3.x, and 2.4.x. The issue stemmed from the implementation's failure to validate that tensor arguments were non-empty, potentially leading to null pointer dereferences (GitHub Advisory).

Technical details

The vulnerability existed in the implementation of MatrixDiag* operations where the code failed to validate tensor arguments before accessing them. The problematic code accessed tensor values directly without proper validation: num_rows = context->input(2).flat()(0); num_cols = context->input(3).flat()(0); padding_value = context->input(4).flat()(0). This implementation could lead to null pointer dereferences when empty tensors were provided as input. The vulnerability received a CVSS v3.1 base score of 2.5 (LOW) from GitHub, though NIST assigned it a higher score of 7.8 (HIGH) (NVD).

Impact

When exploited, this vulnerability could cause null pointer dereferences in TensorFlow applications. This could be triggered by providing empty tensors as input to the MatrixDiag* operations, potentially leading to application crashes and denial of service conditions (GitHub Advisory).

Exploitability

The vulnerability could be exploited by providing specially crafted inputs to the MatrixDiag* operations. A proof of concept exploit was demonstrated using Python code: import tensorflow as tf; d = tf.convert_to_tensor([],dtype=tf.float32); p = tf.convert_to_tensor([],dtype=tf.float32); tf.raw_ops.MatrixDiagV2(diagonal=d, k=0, num_rows=0, num_cols=0, padding_value=p). The issue could be reproduced using either MatrixDiagV2 or MatrixDiagV3 operations (GitHub Advisory).

Mitigation and workarounds

The vulnerability was patched in TensorFlow 2.5.0 and backported to versions 2.4.2, 2.3.3, 2.2.3, and 2.1.4. The fix involved adding proper validation checks for tensor arguments before accessing them, as implemented in commit a7116dd3913c4a4afd2a3a938573aa7c785fdfc6 (GitHub Commit).

Additional resources

Linux Distribution fix status

Fix availability across major Linux distributions and their releases.

Arch Linux

Fixed

rolling

tensorflow: 2.5.0-1

Fixed

SourceThis report was generated using AI

Related Python vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

CVE-2026-59971CRITICAL10
  • Python logoPython
  • mysql-mcp-server
NoYesSep 11, 2026
CVE-2026-59177HIGH8.8
  • Python logoPython
  • esphome-device-builder
NoYesSep 09, 2026
CVE-2026-88006MEDIUM6.5
  • Python logoPython
  • open-webui
NoYesSep 10, 2026
CVE-2026-88005MEDIUM6.5
  • Python logoPython
  • open-webui
NoYesSep 10, 2026
CVE-2026-49836MEDIUM4.6
  • Python logoPython
  • psd-tools
NoYesSep 10, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management