Invalid free() call in Nanopb
Key facts
- Attack vector
- Network
- Privileges required
- Low
- User interaction
- None
- Attack complexity
- Low
- Impact type
- —
- Confidentiality · integrity · availability
- None · High · Low
- Fix status
- Fixed
Attack profile from CVSS 3.1 · CNA. Fix status from CNA and GitHub.
Summary
Nanopb is a small code-size Protocol Buffers implementation in ansi C. In Nanopb before versions 0.3.9.8 and 0.4.5, decoding a specifically formed message can cause invalid `free()` or `realloc()` calls if the message type contains an `oneof` field, and the `oneof` directly contains both a pointer field and a non-pointer field. If the message data first contains the non-pointer field and then the pointer field, the data of the non-pointer field is incorrectly treated as if it was a pointer value. Such message data rarely occurs in normal messages, but it is a concern when untrusted data is parsed. This has been fixed in versions 0.3.9.8 and 0.4.5. See referenced GitHub Security Advisory for more information including workarounds.
Why it matters now
SSVC decision points
Not available: CISA has not published SSVC decision points for this record.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| nanopb | nanopb | 0.3.2 – 0.3.9.7; 0.4.0 – 0.4.4 | — | No fix listed | CNA |
| — | nanopb (PyPI) | 0.3.2 to before 0.3.9.8 | 0.3.9.8 | Patch available | GHSA-7mv5-5mxh-qg88 |
| — | nanopb (PyPI) | 0.4.0 to before 0.4.5 | 0.4.5 | Patch available | GHSA-7mv5-5mxh-qg88 |
- nanopb Vendornanopb Affected 0.3.2 – 0.3.9.7; 0.4.0 – 0.4.4 Fixed in — No fix listed CNA
- nanopb (PyPI) Vendor— Affected 0.3.2 to before 0.3.9.8 Fixed in 0.3.9.8 Patch available GHSA-7mv5-5mxh-qg88
- nanopb (PyPI) Vendor— Affected 0.4.0 to before 0.4.5 Fixed in 0.4.5 Patch available GHSA-7mv5-5mxh-qg88
Remediation
- Fix · GHSA-7mv5-5mxh-qg88 nanopb (PyPI) Fixed in 0.3.9.8 Advisory →
- Fix · GHSA-7mv5-5mxh-qg88 nanopb (PyPI) Fixed in 0.4.5 Advisory →
Timeline
- 2026-10-02 Threatist record created from CVE-2021-21401
- 2026-10-03 Alias added: GHSA-7mv5-5mxh-qg88
References
Exploit 2
Advisory 2
More Nanopb vulnerabilities
- TI-2014-08406 Nanopb before 0.3.1 allows size_t overflows in pb_dec_bytes and pb_dec_string. CVSS 3.1CRITICAL 9.8
- TI-2020-04291 Out-of-memory condition in Nanopb is potentially exploitable CVSS 3.1CRITICAL 9.8
- TI-2020-16064 Memory leak in nanopb CVSS 3.1HIGH 7.5
Sources
- CVE-2021-21401 · CVE Program
- CVE-2021-21401 · NVD
- FIRST EPSS
- GHSA-7mv5-5mxh-qg88 · GitHub Advisory Database · CC BY 4.0
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences