Skip to content
Fencer Vulns
high 7.1

CVE-2021-21401 json

Invalid free() call in Nanopb

published 2021-03-23 5 y ago modified 2026-07-08 4 mo ago also GHSA-7mv5-5mxh-qg88 , PYSEC-2021-432 , EUVD-2021-0139

cvss
7.1
version 3.1, CNA
cisa kev
Not listed
not in CISA's catalog
epss
1.8%
EPSS 1.8% chance of exploitation in 30 days, percentile 78%
public exploits
0
none known

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.

Patch / fix

  • pypi nanopb 0.3.9.8, 0.4.5
  • nanopb_project nanopb 0.3.9.8, 0.4.5
  • nanopb Debian 14, Debian 13, Debian 12 0.4.4-2

debian advisories DEBIAN-CVE-2021-21401

  • nanopb Ubuntu Pro 20.04 LTS 0.4.1-1ubuntu0.1~esm1

ubuntu advisories UBUNTU-CVE-2021-21401

Ubuntu security data © Canonical Ltd., from https://github.com/canonical/ubuntu-security-notices via OSV; changed: normalised to fixed package versions per release. CC BY-SA 4.0

  • nanopb openSUSE Tumbleweed 0.4.5-1.3

opensuse advisories openSUSE-SU-2024:11074-1

Exploit prediction

1.81% chance of exploitation in the next 30 days, higher than 78% of all scored CVEs (FIRST EPSS, 2026-11-08).

Exploits and checks

  • github.com https://github.com/nanopb/nanopb/security/advisories/GHSA-7mv5-5mxh-qg88 referenced PoC, tagged "exploit" by a source, unverified
  • github.com https://github.com/nanopb/nanopb/issues/647 referenced PoC, tagged "exploit" by a source, unverified

CVSS scores

assigned by version score vector
CNA 3.1 7.1 CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:L
NVD 3.1 7.1 CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:L
NVD 2.0 5.5 AV:N/AC:L/Au:S/C:N/I:P/A:P
GitHub 3.1 7.1 CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:L

Affected packages

ecosystem package affected fixed in
pypi nanopb
>=0.3.2, <0.3.9.8
>=0.4.0, <0.4.5
<0.3.9.8
0.3.9.8
0.4.5

Affected products

  • nanopb nanopb

Classification

Weakness
  • CWE-763 Release of Invalid Pointer or Reference

References

Sources

Fencer Vulns keeps one entry per vulnerability: the CVE id wins, then GHSA, and records that alias each other are merged, except that two CVEs always keep separate entries. The same data is available as JSON.