LiveActive security incident?Get immediate response
CVE Record

CVE-2021-37640: Integer division by 0 in sparse reshaping in TensorFlow

TensorFlow is an end-to-end open source platform for machine learning. In affected versions the implementation of `tf.raw_ops.SparseReshape` can be made to trigger an integral division by 0 exception. The [implementation](https://github.com/tensorflow/tensorflow/blob/8d72537c6abf5a44103b57b9c2e22c14f5f49698/tensorflow/core/kernels/reshape_util.cc#L176-L181) calls the reshaping functor whenever there is at least an index in the input but does not check that shape of the input or the target shape have both a non-zero number of elements. The [reshape functor](https://github.com/tensorflow/tensorflow/blob/8d72537c6abf5a44103b57b9c2e22c14f5f49698/tensorflow/core/kernels/reshape_util.cc#L40-L78) blindly divides by the dimensions of the target shape. Hence, if this is not checked, code will result in a division by 0. We have patched the issue in GitHub commit 4923de56ec94fff7770df259ab7f2288a74feb41. The fix will be included in TensorFlow 2.6.0. We will also cherrypick this commit on TensorFlow 2.5.1 as this is the other affected version.

MediumCVSS 5.5Not KEV-listedUpdated
Glexia's TakeAutomated analysismoderate

Security readout for executives and security teams

Plain-English summary

CVE-2021-37640 can make TensorFlow crash when sparse reshape input is malformed. The business impact is availability: affected ML jobs or services using TensorFlow may terminate unexpectedly if reachable by a low-privileged local user or workload submitter.

Executive priority

Treat as a moderate operational reliability issue. It is not described as data theft or remote takeover, but it can disrupt ML workloads where untrusted or low-privileged users can influence TensorFlow operations.

Technical view

TensorFlow's tf.raw_ops.SparseReshape could call reshape logic without confirming input and target shapes both had non-zero element counts. The reshape functor then divided by target dimensions, causing an integer divide-by-zero exception. Sources identify CWE-369 and CVSS 5.5 with high availability impact only.

Likely exposure

Exposure is most likely in TensorFlow deployments before the fixed 2.5.1 or 2.6.0 releases, especially shared ML platforms, notebooks, batch systems, or services where users can influence tensors or TensorFlow ops. The source bundle does not identify non-TensorFlow products.

Exploitation context

No KEV listing is provided, and the supplied sources do not claim active exploitation. The CVSS vector indicates local access, low attack complexity, low privileges, no user interaction, and availability impact without confidentiality or integrity impact.

Researcher notes

The root cause is missing zero-element shape validation before invoking sparse reshape logic. The public fix is commit 4923de56ec94fff7770df259ab7f2288a74feb41. Evidence is sufficient for affected component and remediation direction, but the bundle provides no real-world exploitation evidence.

Mitigation direction

  • Upgrade TensorFlow to a fixed release: 2.5.1, 2.6.0, or later.
  • Prioritize shared ML environments and services accepting user-controlled tensor inputs.
  • If upgrade is delayed, restrict untrusted access to TensorFlow workloads using SparseReshape.
  • Review the TensorFlow advisory for exact branch and package guidance.

Validation and detection

  • Inventory TensorFlow package versions across services, notebooks, images, and training workers.
  • Confirm no deployed environment remains on an affected TensorFlow version.
  • Identify code paths or jobs using tf.raw_ops.SparseReshape or sparse reshape wrappers.
  • Check dependency locks and container images for stale TensorFlow builds.
Prepared
Confidence
high
Sources
4

Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.

Potential ATT&CK relevance

Conservative CVE-to-ATT&CK context

These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.

ATT&CK lookup starting points

Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.

cwe · low confidence lookup

CWE-369: Exact CWE lookup

Use the exact CWE identifier as the starting point before reviewing related ATT&CK behavior. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.

Open ATT&CK lookup
cve · low confidence lookup

CVE-2021-37640 mapping review

Open the CVE-to-ATT&CK bridge for reviewed, inferred, or future official mappings tied to this CVE.

Open ATT&CK lookup
Vulnerability profileCVE Program record
Severity
Medium
CVSS
5.5 (3.1)
Known Exploited
No
Published

Vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H

Official CVE source material

CNA and ADP enrichment extracted from CVE v5

These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.

1CVSS vectors
0Timeline events
0ADP providers
3Source links

CVSS vector scores

1 official score

We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.

ScoreVersionSeverityVectorExploitImpactSource
5.5CVSS 3.1MediumCVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H1.83.6Primary CVE score

Vulnerability scoring details

Base CVSS 3.1 score

5.5Medium
CVSS 3.1 vector shape for CVE-2021-37640Attack VectorAttack ComplexityPrivileges RequiredUser InteractionScopeConfidentiality ImpactIntegrity ImpactAvailability Impact

Vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H

Attack Vector
NetworkAdjacentLocalPhysical
Attack Complexity
LowHigh
Privileges Required
NoneLowHigh
User Interaction
NoneRequired
Scope
ChangedUnchanged
Confidentiality Impact
HighLowNone
Integrity Impact
HighLowNone
Availability Impact
HighLowNone
Affected products

Products and packages named in the record

VendorProductVersion / packageStatus
tensorflowtensorflow< 2.5.1Listed
Weakness

CWE details

CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.

CWE-369 · source CWE mapping

Divide By Zero

Divide By Zero represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.