CVE-2024-45620: Incorrect handling length of buffers or files in pkcs15init
The reported issues are part of the card enrollment process using the pkcs15-init tool. The attack requires a crafted USB device or smart card that would present the system with specially crafted responses to the APDUs, so they are considered high complexity and low severity.
When buffers are partially filled with data, uninitialized parts of the buffer can be incorrectly accessed. The uninitialized variables were reflected in the following functions:
- starcos_write_pukey
- lack of checking file length (https://github.com/OpenSC/OpenSC/blob/d5a5b5428ef1b33c71057fd173e541cdc0273485/src/pkcs15init/pkcs15-starcos.c#L671)
- found via fuzz_pkcs15init
- fixed with a1bcc6516f43d570899820d259b71c53f8049168
- iasecc_sdo_parse, iasecc_se_parse
- missing checks for accessing data buffer (https://github.com/OpenSC/OpenSC/blob/d5a5b5428ef1b33c71057fd173e541cdc0273485/src/libopensc/iasecc-sdo.c#L764 and https://github.com/OpenSC/OpenSC/blob/d5a5b5428ef1b33c71057fd173e541cdc0273485/src/libopensc/iasecc-sdo.c#L322)
- found via fuzz_pkcs15init
- fixed with
- 6baa19596598169d652659863470a60c5ed79ecd
- 468a314d76b26f724a551f2eb339dd17c856cf18
- setcos_generate_key
- missing check for data length (https://github.com/OpenSC/OpenSC/blob/d5a5b5428ef1b33c71057fd173e541cdc0273485/src/pkcs15init/pkcs15-setcos.c#L507)
- found via fuzz_pkcs15init
- fixed with e20ca25204c9c5e36f53ae92ddf017cd17d07e31
- sc_hsm_determine_free_id
- incorrect checking of file list length (https://github.com/OpenSC/OpenSC/blob/d5a5b5428ef1b33c71057fd173e541cdc0273485/src/pkcs15init/pkcs15-sc-hsm.c#L143)
- found via fuzz_pkcs15init
- fixed with 2b6cd52775b5448f6a993922a30c7a38d9626134
Affected versions: all before 0.26.0
Originally reported by Matteo Marini (Sapienza University of Rome)
CVSS:3.1/AV:P/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L (3.9)