Miggo Logo

CVE-2021-21401: nanopb vulnerable to invalid free() call with oneofs and PB_ENABLE_MALLOC

7.1

CVSS Score
3.1

Basic Information

EPSS Score
0.42442%
Published
8/30/2024
Updated
8/30/2024
KEV Status
No
Technology
TechnologyPython

Technical Details

CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:L
Package NameEcosystemVulnerable VersionsFirst Patched Version
nanopbpip>= 0.3.2, < 0.3.9.80.3.9.8
nanopbpip>= 0.4.0, < 0.4.50.4.5

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability stems from how oneof field switching was handled in pb_release_union_field. The commit diff shows a critical fix where pointer fields are explicitly initialized to NULL when switching oneof members. This addresses the core issue where previous non-pointer data could be misinterpreted as a pointer. The function's role in managing union field cleanup directly matches the vulnerability description of invalid pointer releases. The high confidence comes from the direct correlation between the patch location, commit message explanation, and the described vulnerability mechanism.

Vulnerable functions

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

WAF Protection Rules

WAF Rule

### Imp**t ***o*in* * sp**i*i**lly *orm** m*ss*** **n **us* inv*li* `*r**()` or `r**llo*()` **lls i* t** m*ss*** typ* *ont*ins *n `on*o*` *i*l*, *n* t** `on*o*` *ir**tly *ont*ins *ot* * point*r *i*l* *n* * non-point*r *i*l*. I* t** m*ss*** **t* *irst

Reasoning

T** vuln*r**ility st*ms *rom *ow on*o* *i*l* swit**in* w*s **n*l** in p*_r*l**s*_union_*i*l*. T** *ommit *i** s*ows * *riti**l *ix w**r* point*r *i*l*s *r* *xpli*itly initi*liz** to NULL w**n swit**in* on*o* m*m**rs. T*is ***r*ss*s t** *or* issu* w**