Skip to content
OpenAdvisories
High · 7.1 Public exploit CVE-2021-21401 EUVD-2021-0139GHSA-7mv5-5mxh-qg88PYSEC-2021-432

Invalid free() call in Nanopb

Published Mar 23, 2021 · Updated Aug 3, 2024 · Assigned by GitHub_M

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 products

VendorProductAffectedFixed
nanopb nanopb >= 0.3.2, <= 0.3.9.7, >= 0.4.0, <= 0.4.4 —

Fixed in Linux distributions

Distributions backport fixes, so the version that fixes this vulnerability differs per release — upgrade to at least the version shown. From the distributions' security trackers and advisories.

ReleasePackageFixed inAdvisory
Debian 14 nanopb 0.4.4-2 —
Debian 13 nanopb 0.4.4-2 —
Debian 12 nanopb 0.4.4-2 —
ReleasePackageFixed inAdvisory
Ubuntu Pro 20.04 LTS nanopb 0.4.1-1ubuntu0.1~esm1 USN-6121-1
ReleasePackageFixed inAdvisory
openSUSE Tumbleweed nanopb 0.4.5-1.3 openSUSE-SU-2024:11074-1

Public exploits

Exploit or proof-of-concept code for this vulnerability is publicly available, which lowers the bar for attackers. Treat it as a reason to patch sooner.

Third-party code, not reviewed by us. Public PoCs are sometimes fake or contain malware. Read the code first and run it only in an isolated lab, against systems you are authorised to test.

GitHub 1 repository

Sources: PoC-in-GitHub, Metasploit Framework, Exploit-DB — updated daily. Only links are listed; no exploit code is hosted here.

Affected packages

EcosystemPackageAffectedFixedRecord
PyPI nanopb >= 0.3.2, < 0.3.9.8 0.3.9.8 GHSA-7mv5-5mxh-qg88
PyPI nanopb >= 0.4.0, < 0.4.5 0.4.5 GHSA-7mv5-5mxh-qg88
PyPI nanopb < 0.3.9.8 · >= 0.4.0, < 0.4.5 0.3.9.8, 0.4.5 PYSEC-2021-432

Advisories 2

References