Python/nanopb/0.4.4.dev1193
Nanopb is a small code-size Protocol Buffers implementation in ansi C. It is especially suitable for use in microcontrollers, but fits any memory restricted system.
https://pypi.org/project/nanopb
Zlib
2 Security Vulnerabilities
nanopb vulnerable to invalid free() call with oneofs and PB_ENABLE_MALLOC
- https://github.com/nanopb/nanopb/security/advisories/GHSA-7mv5-5mxh-qg88
- https://nvd.nist.gov/vuln/detail/CVE-2021-21401
- https://github.com/nanopb/nanopb/issues/647
- https://github.com/nanopb/nanopb/commit/4a375a560651a86726e5283be85a9231fd0efe9c
- https://github.com/nanopb/nanopb/commit/e2f0ccf939d9f82931d085acb6df8e9a182a4261
- https://github.com/nanopb/nanopb/blob/c9124132a604047d0ef97a09c0e99cd9bed2c818/CHANGELOG.txt#L1
- https://github.com/pypa/advisory-database/tree/main/vulns/nanopb/PYSEC-2021-432.yaml
- https://github.com/advisories/GHSA-7mv5-5mxh-qg88
Impact
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.
Patches
Preliminary patch is available on git for 0.4.x and 0.3.x branches. The fix will be released in versions 0.3.9.8 and 0.4.5 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 all fields inside the oneof to FT_POINTER. This ensures that the data contained inside the union is always a valid pointer. * Heap implementations that guard against invalid free() provide a partial mitigation. Depending on the message type, the pointer value may be attacker controlled and can be used to bypass heap protections.
References
Bug report: https://github.com/nanopb/nanopb/issues/647
For more information
If you have any questions or comments about this advisory, comment on the bug report linked above.
Memory leak in Nanopb
- https://github.com/nanopb/nanopb/security/advisories/GHSA-85rr-4rh9-hhwh
- https://nvd.nist.gov/vuln/detail/CVE-2020-26243
- https://github.com/advisories/GHSA-85rr-4rh9-hhwh
- https://github.com/nanopb/nanopb/issues/615
- https://github.com/nanopb/nanopb/commit/4fe23595732b6f1254cfc11a9b8d6da900b55b0c
- https://github.com/nanopb/nanopb/blob/2b48a361786dfb1f63d229840217a93aae064667/CHANGELOG.txt
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.
176 Other Versions
| Version | License | Security | Released | |
|---|---|---|---|---|
| 0.4.1.dev1003 | Zlib | 2 | 2020-01-17 - 03:39 | about 6 years |
| 0.4.1.dev997 | Zlib | 2 | 2020-01-16 - 03:39 | about 6 years |
| 0.4.1.dev996 | Zlib | 2 | 2020-01-14 - 03:39 | about 6 years |
| 0.4.1.dev988 | Zlib | 2 | 2020-01-13 - 03:39 | about 6 years |
| 0.4.1.dev987 | Zlib | 2 | 2020-01-11 - 03:39 | about 6 years |
| 0.4.1.dev985 | Zlib | 2 | 2020-01-10 - 03:39 | about 6 years |
| 0.4.1.dev980 | Zlib | 2 | 2020-01-07 - 03:39 | about 6 years |
| 0.4.1.dev978 | Zlib | 2 | 2020-01-03 - 03:39 | over 6 years |
| 0.4.1.dev971 | Zlib | 2 | 2020-01-01 - 03:39 | over 6 years |
| 0.4.1.dev964 | Zlib | 2 | 2019-12-30 - 03:39 | over 6 years |
| 0.4.1.dev962 | Zlib | 2 | 2019-12-29 - 03:39 | over 6 years |
| 0.4.1.dev961 | Zlib | 2 | 2019-12-27 - 03:39 | over 6 years |
| 0.4.1.dev959 | Zlib | 2 | 2019-12-21 - 03:39 | over 6 years |
| 0.4.0 | Zlib | 2 | 2019-12-20 - 13:06 | over 6 years |
| 0.4.0.dev955 | Zlib | 2019-12-20 - 03:39 | over 6 years | |
| 0.4.0.dev945 | Zlib | 2019-12-19 - 03:39 | over 6 years | |
| 0.4.0.dev932 | Zlib | 2019-12-18 - 03:39 | over 6 years | |
| 0.4.0.dev912 | Zlib | 2019-12-17 - 03:39 | over 6 years | |
| 0.4.0.dev902 | Zlib | 2019-12-16 - 03:39 | over 6 years | |
| 0.4.0.dev892 | Zlib | 2019-12-14 - 03:39 | over 6 years | |
| 0.4.0.dev891 | Zlib | 2019-12-13 - 19:57 | over 6 years | |
| 0.3.9.8 | Zlib | 2021-03-22 - 12:56 | about 5 years | |
| 0.3.9.7 | Zlib | 1 | 2020-11-25 - 11:55 | over 5 years |
| 0.3.9.6 | Zlib | 2 | 2020-06-23 - 09:00 | almost 6 years |
| 0.3.9.5 | Zlib | 2 | 2020-02-02 - 03:39 | about 6 years |
| 0.3.9.4.post3 | Zlib | 2019-12-14 - 07:52 | over 6 years |
