GHSA-85rr-4rh9-hhwh

Suggest an improvement
Source
https://github.com/advisories/GHSA-85rr-4rh9-hhwh
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2020/11/GHSA-85rr-4rh9-hhwh/GHSA-85rr-4rh9-hhwh.json
JSON Data
https://api.test.osv.dev/v1/vulns/GHSA-85rr-4rh9-hhwh
Aliases
Related
Published
2020-11-25T16:53:27Z
Modified
2023-11-01T04:52:43.856872Z
Severity
  • 7.5 (High) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H CVSS Calculator
Summary
Memory leak in Nanopb
Details

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

Database specific
{
    "nvd_published_at": null,
    "github_reviewed_at": "2020-11-25T16:52:43Z",
    "severity": "MODERATE",
    "github_reviewed": true,
    "cwe_ids": [
        "CWE-119",
        "CWE-20"
    ]
}
References

Affected packages

PyPI / nanopb

Package

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0.3.2
Fixed
0.3.9.7

Affected versions

0.*

0.3.9.4.post3
0.3.9.5
0.3.9.6

Database specific

{
    "last_known_affected_version_range": "<= 0.3.9.6"
}

PyPI / nanopb

Package

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0.4.0
Fixed
0.4.4

Affected versions

0.*

0.4.0
0.4.1.dev959
0.4.1.dev961
0.4.1.dev962
0.4.1.dev964
0.4.1.dev971
0.4.1.dev978
0.4.1.dev980
0.4.1.dev985
0.4.1.dev987
0.4.1.dev988
0.4.1.dev996
0.4.1.dev997
0.4.1.dev1003
0.4.1.dev1007
0.4.1.dev1012
0.4.1.dev1013
0.4.1.dev1017
0.4.1.dev1036
0.4.1
0.4.2.dev1041
0.4.2.dev1043
0.4.2.dev1044
0.4.2.dev1045
0.4.2.dev1048
0.4.2.dev1050
0.4.2.dev1053
0.4.2.dev1054
0.4.2.dev1055
0.4.2.dev1058
0.4.2.dev1059
0.4.2.dev1063
0.4.2.dev1066
0.4.2.dev1070
0.4.2.dev1071
0.4.2.dev1072
0.4.2.dev1076
0.4.2.dev1088
0.4.2.dev1091
0.4.2
0.4.3.dev1128
0.4.3.dev1131
0.4.3.dev1132
0.4.3.dev1133
0.4.3.dev1137
0.4.3.dev1150
0.4.3.dev1164
0.4.3.dev1172
0.4.3.dev1175
0.4.3.dev1177
0.4.3
0.4.4.dev1181
0.4.4.dev1182
0.4.4.dev1184
0.4.4.dev1185
0.4.4.dev1188
0.4.4.dev1192
0.4.4.dev1193