Miggo Logo

CVE-2021-29593: Division by zero in TFLite's implementation of `BatchToSpaceNd`

2.5

CVSS Score
3.1

Basic Information

EPSS Score
0.0254%
Published
5/21/2021
Updated
10/31/2024
KEV Status
No
Technology
TechnologyPython

Technical Details

CVSS Vector
CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:L
Package NameEcosystemVulnerable VersionsFirst Patched Version
tensorflowpip< 2.1.42.1.4
tensorflowpip>= 2.2.0, < 2.2.32.2.3
tensorflowpip>= 2.3.0, < 2.3.32.3.3
tensorflowpip>= 2.4.0, < 2.4.22.4.2
tensorflow-cpupip< 2.1.42.1.4
tensorflow-cpupip>= 2.2.0, < 2.2.32.2.3
tensorflow-cpupip>= 2.3.0, < 2.3.32.3.3
tensorflow-cpupip>= 2.4.0, < 2.4.22.4.2
tensorflow-gpupip< 2.1.42.1.4
tensorflow-gpupip>= 2.2.0, < 2.2.32.2.3
tensorflow-gpupip>= 2.3.0, < 2.3.32.3.3
tensorflow-gpupip>= 2.4.0, < 2.4.22.4.2

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability stems directly from lines 81-82 in batch_to_space_nd.cc, which are part of the ResizeOutputTensor function. The code checks if output_batch_size is divisible by block_shape[dim] (TF_LITE_ENSURE_EQ) but does not validate that block_shape[dim] itself is non-zero first. The patch adds a TF_LITE_ENSURE check for block_shape[dim] != 0, confirming this was the vulnerable location. The function's role in processing attacker-controlled block_shape inputs and performing division makes it the clear vulnerability source.

Vulnerable functions

Only Mi**o us*rs **n s** t*is s**tion

WAF Protection Rules

WAF Rule

### Imp**t T** impl*m*nt*tion o* t** `**t**ToSp***N*` T*Lit* op*r*tor is [vuln*r**l* to * *ivision *y z*ro *rror](*ttps://*it*u*.*om/t*nsor*low/t*nsor*low/*lo*/****************************************/t*nsor*low/lit*/k*rn*ls/**t**_to_sp***_n*.**#L**-

Reasoning

T** vuln*r**ility st*ms *ir**tly *rom lin*s **-** in **t**_to_sp***_n*.**, w*i** *r* p*rt o* t** R*siz*OutputT*nsor *un*tion. T** *o** ****ks i* output_**t**_siz* is *ivisi*l* *y *lo*k_s**p*[*im] (T*_LIT*_*NSUR*_*Q) *ut *o*s not v*li**t* t**t *lo*k_s