GHSA-7mv5-5mxh-qg88

Suggest an improvement
Source
https://github.com/advisories/GHSA-7mv5-5mxh-qg88
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2024/08/GHSA-7mv5-5mxh-qg88/GHSA-7mv5-5mxh-qg88.json
JSON Data
https://api.test.osv.dev/v1/vulns/GHSA-7mv5-5mxh-qg88
Aliases
Related
Published
2024-08-30T18:45:41Z
Modified
2024-08-30T18:49:46.963379Z
Severity
  • 7.1 (High) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:L CVSS Calculator
  • 7.1 (High) CVSS_V4 - CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:H/VA:L/SC:N/SI:N/SA:N CVSS Calculator
Summary
nanopb vulnerable to invalid free() call with oneofs and PB_ENABLE_MALLOC
Details

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.

Database specific
{
    "nvd_published_at": "2021-03-23T18:15:00Z",
    "cwe_ids": [
        "CWE-763"
    ],
    "severity": "HIGH",
    "github_reviewed": true,
    "github_reviewed_at": "2024-08-30T18:45:41Z"
}
References

Affected packages

PyPI / nanopb

Package

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0.3.2
Fixed
0.3.9.8

Affected versions

0.*

0.3.9.4.post3
0.3.9.5
0.3.9.6
0.3.9.7

PyPI / nanopb

Package

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0.4.0
Fixed
0.4.5

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
0.4.4
0.4.5.dev1212
0.4.5.dev1214
0.4.5.dev1215
0.4.5.dev1217
0.4.5.dev1220
0.4.5.dev1224
0.4.5.dev1233
0.4.5.dev1234