CVE-2020-26243: Nanopb Memory Leak Vulnerability

MODERATE
Advisory Identifier: GHSA-85rr-4rh9-hhwh
CVSS 7.5
CWE-20 CWE-119
Published
Advisory Summary

CVE-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

CVE Identifier CVE-2020-26243
GHSA Identifier GHSA-85rr-4rh9-hhwh
Severity MODERATE
CVSS v3.1 Base Score 7.5
CWE Classification CWE-20: Improper Input Validation
Affected Product Nanopb
Package Ecosystem PyPI
Published Date
Last Updated

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).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (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.

nanopb fixed: 0.3.9.7
pip install nanopb>=0.3.9.7
nanopb fixed: 0.4.4
pip install nanopb>=0.4.4
Verify Direct and Transitive Dependencies

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

### Impact Decoding 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. ### Patches Preliminary 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. ### Workarounds Following workarounds are available: * 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. * 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. * Use an arena allocator for nanopb, to make sure all memory can be released afterwards. ### References Bug report: https://github.com/nanopb/nanopb/issues/615 ### For more information If you have any questions or comments about this advisory, comment on the bug report linked above.

CVE-2020-26243 Affected Nanopb Versions

2 component(s)
Fixed Versions:
0.3.9.70.4.4
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?
CVE-2020-26243 is a security vulnerability in Nanopb involving Memory leak in Nanopb under CWE-20: Improper Input Validation.
Which Nanopb versions are affected?
Affected versions include releases prior to 0.3.9.7, 0.4.4 across affected packages: nanopb.
What version fixes CVE-2020-26243?
Upgrading to 0.3.9.7, 0.4.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is nanopb affected?
Yes, nanopb is affected in releases prior to 0.3.9.7, 0.4.4. Upgrade your dependency to 0.3.9.7, 0.4.4 or later.
What is the CVSS score of CVE-2020-26243?
CVE-2020-26243 has a CVSS v3.1 base score of 7.5 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2020-26243?
CVE-2020-26243 is classified under CWE-20: Improper Input Validation (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.).
How can I check PyPI dependencies for CVE-2020-26243?
Run the dependency tree command: 'pip show nanopb'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "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
  }
}