CVE-2020-26243: Memory leak in Nanopb

nanopb Updated 02 Oct 2025

Summary

25/11/2020
Yes i
Moderate
7.5

CVE-2020-26243: Memory leak in Nanopb. Affects nanopb across 2 version ranges.

>= 0.3.2, < 0.3.9.7 >= 0.4.0, < 0.4.4

Fixed in 0.3.9.7 or 0.4.4, depending on the release line you run. How to fix ↓

Also tracked for

The same CVE-2020-26243 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

Nanopb is an open-source library that provides a simple way to encode and decode Protocol Buffers data. It is commonly used in Python projects and is available on PyPI. Nanopb allows developers to efficiently serialize and deserialize structured data, making it easier to exchange information between different systems. However, a vulnerability has been discovered in Nanopb that can lead to a memory leak under certain conditions.

Vulnerability Detail

The vulnerability in Nanopb arises when decoding a specially crafted message that contains a oneof field with a static submessage that contains a dynamic field. If the message being decoded contains the submessage multiple times, memory can be leaked when dynamic allocation is enabled. While this scenario is rare in normal messages, it becomes a concern when parsing untrusted data. The memory leak can potentially exhaust system resources and lead to denial-of-service attacks.

How To Fix

Fixed versions by release line

The minimum fixed version depends on the release line you run.

  • >= 0.3.2, < 0.3.9.7 0.3.9.7
    pip install --upgrade "nanopb==0.3.9.7"
  • >= 0.4.0, < 0.4.4 0.4.4
    pip install --upgrade "nanopb==0.4.4"

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

If updating to the patched versions is not immediately feasible, there are a few workarounds available:

  1. Set the option no_unions for the oneof field. This will generate separate fields instead of a C union, avoiding the problematic code.
  2. Set the type of the submessage field inside the oneof to FT_POINTER. This will dynamically allocate the entire submessage, bypassing the problematic code.
  3. Use an arena allocator for Nanopb to ensure that all memory can be released afterwards.

Conclusion

The memory leak vulnerability in Nanopb can have serious consequences if exploited by an attacker. It is crucial to update to the patched versions or implement the provided workarounds to mitigate the risk. For further support on vulnerability remediation, you can contact DevNack.com.

See every vulnerability recorded for nanopb →

Share this vulnerability

FAQ

Nanopb is an open-source library that provides a simple way to encode and decode Protocol Buffers data. It is commonly used in Python projects for efficient serialization and deserialization of structured data.

The vulnerability can lead to a memory leak when decoding specific messages that contain a oneof field with a static submessage containing a dynamic field. This can be exploited by an attacker to exhaust system resources and potentially launch denial-of-service attacks.

To fix the vulnerability, it is recommended to update to Nanopb versions 0.3.9.7 or 0.4.4 once they are available. These versions include a patch that addresses the memory leak issue.

Yes, if updating to the patched versions is not immediately feasible, there are a few workarounds that can be implemented. These include setting the no_unions option for the oneof field, setting the type of the submessage field to FT_POINTER, or using an arena allocator for Nanopb.

You can find more information about this vulnerability in the bug report on the Nanopb GitHub repository.

Related vulnerabilities

Recent vulnerabilities recorded for nanopb.

How To Fix

Fixed versions by release line

The minimum fixed version depends on the release line you run.

  • >= 0.3.2, < 0.3.9.7 0.3.9.7
    pip install --upgrade "nanopb==0.3.9.7"
  • >= 0.4.0, < 0.4.4 0.4.4
    pip install --upgrade "nanopb==0.4.4"

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback