CVE-2021-21401
Invalid free() call in Nanopb
Also known as GHSA-7mv5-5mxh-qg88, PYSEC-2021-432
Mitigation
- Upgrade nanopb to one of 0.3.9.8, 0.4.5 (or later in the same release line).
Who should check
- Projects that depend on PyPI package nanopb (>= 0.3.2, < 0.3.9.8)
- Anyone running nanopb >= 0.3.2, <= 0.3.9.7; >= 0.4.0, <= 0.4.4
Vulnerability facts
- Affected
- nanopb >= 0.3.2, < 0.3.9.8
- Fixed in
- 0.3.9.8, 0.4.5
- Exploited in the wild
- Not in CISA KEV
- Public exploit / PoC
- Yes: see the exploit references below
- Remote exploitation
- Remote, login needed
- CVSS
- 7.1 (v3.1, CNA)CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:LOpen in CVSS calculator
Show all 8 CVSS metrics
- Attack vector: Network
- Attack complexity: Low
- Privileges required: Low
- User interaction: None
- Scope: Unchanged
- Confidentiality impact: None
- Integrity impact: High
- Availability impact: Low
- EPSS
- 1.81% chance of exploitation in 30 days (percentile 79, 2026-11-26)
- CWE
- CWE-763
- Modified
Description
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.
Affected and fixed versions
Check your systems with an agent
Paste this into Claude Code, Cursor or another coding agent. It only reads; it changes nothing.
Check whether anything I run is affected by CVE-2021-21401. Work read-only: do not install, upgrade, delete or change anything. Details: https://flawdb.com/CVE-2021-21401.md Affected: nanopb >= 0.3.2, < 0.3.9.8 Fixed in: 0.3.9.8, 0.4.5 Steps: 1. Search this machine and project for nanopb (PyPI), nanopb: dependency manifests and lockfiles, installed packages, container images and running services. 2. For each match, note the installed version and whether it is inside the affected range. 3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
References
Vendor advisories
Patches
Exploits and PoCs
FAQ
Is CVE-2021-21401 being exploited?
There is no confirmed exploitation: CVE-2021-21401 is not in the CISA Known Exploited Vulnerabilities catalog. Public exploit code or a proof of concept is available. EPSS estimates a 1.81% chance of exploitation in the next 30 days (as of 2026-11-26).
How serious is CVE-2021-21401?
High: CVSS 7.1 (v3.1, scored by CNA). Remote, login needed.
Which versions are affected by CVE-2021-21401?
nanopb >= 0.3.2, < 0.3.9.8.
Is there a fix for CVE-2021-21401?
Yes. Fixed in 0.3.9.8, 0.4.5. Upgrade nanopb to one of 0.3.9.8, 0.4.5 (or later in the same release line).
How do I check if I'm affected by CVE-2021-21401?
Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.