CVE-2021-29521
Python vulnerability analysis and mitigation

Overview

TensorFlow, an end-to-end open source platform for machine learning, was found to have a vulnerability (CVE-2021-29521) where specifying a negative dense shape in tf.raw_ops.SparseCountSparseOutput results in a segmentation fault. The vulnerability was discovered in versions >2.3.0 and <2.5.0, and was patched in versions 2.3.3 and 2.4.2. The issue was reported by Yakun Zhang and Ying Wang of Baidu X-Team (GitHub Advisory).

Technical details

The vulnerability occurs because the implementation assumes the first element of the dense shape is always positive and uses it to initialize a BatchedMap (i.e., std::vector) data structure. If the shape tensor has more than one element, num_batches is the first value in shape. When a negative dense shape is provided, it breaks std::vector invariants, leading to a segmentation fault. The issue can be triggered by providing negative values in the dense_shape argument (GitHub Advisory, TF Commit).

Impact

The vulnerability results in a segmentation fault being thrown from the standard library when exploited, which can lead to application crashes. This could potentially be used to cause denial of service in applications using the affected TensorFlow versions (GitHub Advisory).

Exploitability

The vulnerability can be exploited by providing specially crafted input with negative values in the dense_shape argument to the tf.raw_ops.SparseCountSparseOutput operation. A proof of concept exists that demonstrates the vulnerability using empty tensors and negative dense shape values (GitHub Advisory).

Mitigation and workarounds

The issue has been patched in TensorFlow versions 2.3.3, 2.4.2, and 2.5.0. The fix ensures that the dense_shape argument is a valid tensor shape by validating that all elements are non-negative. Users are advised to upgrade to these patched versions to mitigate the vulnerability (GitHub Advisory).

Additional resources


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-50027CRITICAL9.8
  • Python logoPython
  • mcp-memory-service
NoYesAug 14, 2026
CVE-2026-49986HIGH7.1
  • Python logoPython
  • neuro-cortex-memory
NoYesAug 14, 2026
CVE-2026-53708MEDIUM6.6
  • Python logoPython
  • mcp-contextforge-gateway
NoYesAug 14, 2026
CVE-2026-47192LOW2.1
  • Python logoPython
  • kas
NoYesAug 14, 2026
CVE-2026-47191LOW2.1
  • Python logoPython
  • kas
NoYesAug 14, 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