CVE-2020-26243: Nanopb Memory Leak Vulnerability
MODERATECVE-2020-26243 is a MODERATE (CVSS 7.5) memory leak vulnerability (CWE-20: Improper Input Validation) affecting Nanopb libraries in the PyPI ecosystem. The issue involves memory leak in nanopb. Remediation is available by upgrading affected packages to version 0.3.9.7, 0.4.4.
CVE-2020-26243 at a Glance
Security Impact
CVSS: 7.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).
How to Fix CVE-2020-26243
To remediate this vulnerability, upgrade all affected Nanopb dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install nanopb>=0.3.9.7
pip install nanopb>=0.4.4
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show nanopb
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2020-26243, inspect your installed packages using pip:
pip show nanopb
Analyze the terminal output to locate any version of Nanopb in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.3.9.7), your application is affected.
Note: The pip show nanopb command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-20: Improper Input Validation, where the product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. In Nanopb, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2020-26243 Affected Nanopb Versions
2 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
nanopb
|
PyPI |
≥ 0.3.2
< 0.3.9.7
|
0.3.9.7
|
|
nanopb
|
PyPI |
≥ 0.4.0
< 0.4.4
|
0.4.4
|
References
Frequently Asked Questions
What is CVE-2020-26243?
Which Nanopb versions are affected?
What version fixes CVE-2020-26243?
Is nanopb affected?
What is the CVSS score of CVE-2020-26243?
What CWE is associated with CVE-2020-26243?
How can I check PyPI dependencies for CVE-2020-26243?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-85rr-4rh9-hhwh",
"modified" : "2021-01-07T22:39:39Z",
"published" : "2020-11-25T16:53:27Z",
"aliases" : [ "CVE-2020-26243" ],
"summary" : "Memory leak in Nanopb",
"details" : "### Impact\nDecoding specifically formed message can leak memory if dynamic allocation is enabled and an oneof field contains a static submessage that contains a dynamic field, and the message being decoded contains the submessage multiple times. This is rare in normal messages, but it is a concern when untrusted data is parsed.\n\n### Patches\nPreliminary patch is [available on git](https://github.com/nanopb/nanopb/commit/edf6dcbffee4d614ac0c2c1b258ab95185bdb6e9) and problem will be patched in versions 0.3.9.7 and 0.4.4 once testing has been completed.\n\n### Workarounds\nFollowing workarounds are available:\n* Set the option `no_unions` for the oneof field. This will generate fields as separate instead of C union, and avoids triggering the problematic code.\n* Set the type of the submessage field inside oneof to `FT_POINTER`. This way the whole submessage will be dynamically allocated and the problematic code is not executed.\n* Use an arena allocator for nanopb, to make sure all memory can be released afterwards.\n\n### References\nBug report: https://github.com/nanopb/nanopb/issues/615\n\n### For more information\nIf you have any questions or comments about this advisory, comment on the bug report linked above.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "nanopb"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0.3.2"
}, {
"fixed" : "0.3.9.7"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 0.3.9.6"
}
}, {
"package" : {
"ecosystem" : "PyPI",
"name" : "nanopb"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0.4.0"
}, {
"fixed" : "0.4.4"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/nanopb/nanopb/security/advisories/GHSA-85rr-4rh9-hhwh"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2020-26243"
}, {
"type" : "WEB",
"url" : "https://github.com/nanopb/nanopb/issues/615"
}, {
"type" : "WEB",
"url" : "https://github.com/nanopb/nanopb/commit/4fe23595732b6f1254cfc11a9b8d6da900b55b0c"
}, {
"type" : "WEB",
"url" : "https://github.com/nanopb/nanopb/blob/2b48a361786dfb1f63d229840217a93aae064667/CHANGELOG.txt"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-119", "CWE-20" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2020-11-25T16:52:43Z",
"nvd_published_at" : null
}
}