|
| 1 | +# [CVE-2024-45616](https://nvd.nist.gov/vuln/detail/CVE-2024-45616): Uninitialized values after incorrect check or usage of APDU response values in libopensc |
| 2 | + |
| 3 | +The reported issues are part of the libopensc library, which makes them accessible from OpenSC tools, PKCS#11 module, minidriver, or CTK. |
| 4 | +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. |
| 5 | + |
| 6 | +The following problems were caused by insufficient control of the response APDU buffer and its length when communicating with the card. |
| 7 | +The uninitialized variables were reflected in these functions: |
| 8 | + |
| 9 | +- [cardos_match_card](https://github.com/OpenSC/OpenSC/blob/d5a5b5428ef1b33c71057fd173e541cdc0273485/src/libopensc/card-cardos.c#L136) |
| 10 | + - uninitialized APDU response buffer, unchecked response length (https://github.com/OpenSC/OpenSC/blob/d5a5b5428ef1b33c71057fd173e541cdc0273485/src/libopensc/card-cardos.c#L136) |
| 11 | + - uninitialized value used later by cardos_match_card |
| 12 | + - found via fuzz_card, fuzz_pkcs11, fuzz_pkcs15_crypt, fuzz_pkcs15_decode |
| 13 | +- _itoa_word, called from [sc_hex_dump](https://github.com/OpenSC/OpenSC/blob/d5a5b5428ef1b33c71057fd173e541cdc0273485/src/libopensc/log.c#L367) |
| 14 | + - the problem arose from cac_cac1_get_certificate function with wrong calculation of certificate length based on the APDU rseponse length (https://github.com/OpenSC/OpenSC/blob/d5a5b5428ef1b33c71057fd173e541cdc0273485/src/libopensc/card-cac1.c#L95-L100) |
| 15 | + - found via fuzz_card, fuzz_pkcs15_crypt, fuzz_pkcs15_decode |
| 16 | +- sc_bin_to_hex |
| 17 | + - the problem arose from auth_select_aid function unchecked SW1 and SW2 after querying for serial number (https://github.com/OpenSC/OpenSC/blob/d5a5b5428ef1b33c71057fd173e541cdc0273485/src/libopensc/card-oberthur.c#L163) |
| 18 | + - found via fuzz_pkcs11, fuzz_pkcs15_encode |
| 19 | +- strcmp, called from sc_asn1_read_tag |
| 20 | + - the problem arose from gids_get_DO function with uncorrect setting of buffer length, when buffer filled with APDU response (https://github.com/OpenSC/OpenSC/blob/master/src/libopensc/card-gids.c#L249-L253) |
| 21 | + - found via fuzz_pkcs15_decode, |
| 22 | +- [asn1_decode](https://github.com/OpenSC/OpenSC/blob/d5a5b5428ef1b33c71057fd173e541cdc0273485/src/libopensc/asn1.c#L1740) |
| 23 | + - do_select not checking APDU response length before accesssing APDu response buffer (https://github.com/OpenSC/OpenSC/blob/d5a5b5428ef1b33c71057fd173e541cdc0273485/src/libopensc/card-mcrd.c#L590) |
| 24 | + - found via fuzz_pkcs11, fuzz_pkcs15_decode |
| 25 | +- [process_fcp](https://github.com/OpenSC/OpenSC/blob/d5a5b5428ef1b33c71057fd173e541cdc0273485/src/libopensc/card-mcrd.c#L508) |
| 26 | + - do_select not checking APDU response length before accesssing APDu response buffer (https://github.com/OpenSC/OpenSC/blob/d5a5b5428ef1b33c71057fd173e541cdc0273485/src/libopensc/card-mcrd.c#L590) |
| 27 | + - fuzz_pkcs15_crypt |
| 28 | +- [dnie_process_fci](https://github.com/OpenSC/OpenSC/blob/d5a5b5428ef1b33c71057fd173e541cdc0273485/src/libopensc/card-dnie.c#L2024) |
| 29 | + - dnie_compose_and_send_apdu lacks checking for APDU reponse length before accessing response (https://github.com/OpenSC/OpenSC/blob/d5a5b5428ef1b33c71057fd173e541cdc0273485/src/libopensc/card-dnie.c#L1180) |
| 30 | + - found via fuzz_pkcs11, fuzz_pkcs15_crypt, fuzz_pkcs15_decode |
| 31 | +- [iso7816_process_fci](https://github.com/OpenSC/OpenSC/blob/d5a5b5428ef1b33c71057fd173e541cdc0273485/src/libopensc/iso7816.c#L463) |
| 32 | + - dnie_compose_and_send_apdu lacks checking for APDU reponse length before accessing response (https://github.com/OpenSC/OpenSC/blob/d5a5b5428ef1b33c71057fd173e541cdc0273485/src/libopensc/card-dnie.c#L1180) |
| 33 | + - found via fuzz_pkcs15_encode |
| 34 | +- [sc_pkcs15init_parse_info](https://github.com/OpenSC/OpenSC/blob/d5a5b5428ef1b33c71057fd173e541cdc0273485/src/pkcs15init/pkcs15-lib.c#L4564), [msc_extract_rsa_public_key](https://github.com/OpenSC/OpenSC/blob/d5a5b5428ef1b33c71057fd173e541cdc0273485/src/libopensc/muscle.c#L620) |
| 35 | + - incorrect return of APDU reponse data length in msc_partial_read_object (https://github.com/OpenSC/OpenSC/blob/d5a5b5428ef1b33c71057fd173e541cdc0273485/src/libopensc/muscle.c#L96) |
| 36 | + - uninitialized part of buffer after actual length accessed by sc_pkcs15init_parse_info |
| 37 | + - found via fuzz_pkcs11, fuzz_pkcs15init |
| 38 | +- [sc_bin_to_hex](https://github.com/OpenSC/OpenSC/blob/d5a5b5428ef1b33c71057fd173e541cdc0273485/src/libopensc/sc.c#L155) |
| 39 | + - unchecked APDU response length when querying for serial number in auth_select_aid (https://github.com/OpenSC/OpenSC/blob/d5a5b5428ef1b33c71057fd173e541cdc0273485/src/libopensc/card-oberthur.c#L163) |
| 40 | + - found via fuzz_pkcs15_crypt, fuzz_pkcs15init, fuzz_pkcs15_decode |
| 41 | +- [gids_read_masterfile](https://github.com/OpenSC/OpenSC/blob/d5a5b5428ef1b33c71057fd173e541cdc0273485/src/libopensc/card-gids.c#L368) |
| 42 | + - the problem arose from gids_get_DO function with uncorrect setting of buffer length, when buffer filled with APDU response (https://github.com/OpenSC/OpenSC/blob/d5a5b5428ef1b33c71057fd173e541cdc0273485/src/libopensc/card-gids.c#L249-L253) |
| 43 | +- [sc_bin_to_hex](https://github.com/OpenSC/OpenSC/blob/d5a5b5428ef1b33c71057fd173e541cdc0273485/src/libopensc/sc.c#L155) |
| 44 | + - unchecked value of APDU response length in function entersafe_get_serialnr (https://github.com/OpenSC/OpenSC/blob/d5a5b5428ef1b33c71057fd173e541cdc0273485/src/libopensc/card-entersafe.c#L1424) |
| 45 | + - found via fuzz_pkcs15_reader |
| 46 | + |
| 47 | +Affected versions: all before 0.26.0 |
| 48 | + |
| 49 | +Originally reported by Matteo Marini (Sapienza University of Rome) |
| 50 | + |
| 51 | +CVSS:3.1[/AV:P/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L](https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator?vector=AV:P/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L) (3.9) |
0 commit comments