|
| 1 | +# [CVE-2025-13763](https://nvd.nist.gov/vuln/detail/CVE-2025-13763): Various uninitialized memory usage during card detection in libopensc |
| 2 | + |
| 3 | +The reported issues are part of the libopensc library, which makes them |
| 4 | +accessible from OpenSC tools, PKCS#11 module, minidriver, or CTK. |
| 5 | +The attack requires a crafted USB device or smart card that would present |
| 6 | +the system with specially crafted responses to the APDUs, so they are |
| 7 | +considered high complexity and low severity. |
| 8 | + |
| 9 | +The uninitialized variables were reflected in these functions: |
| 10 | + |
| 11 | +- [authentic_parse_credential_data](https://github.com/OpenSC/OpenSC/blob/23dcca082fa35eb454f8a2add163dfd506eab434/src/libopensc/card-authentic.c#L300) |
| 12 | + - The function `authentic_get_tagged_data()` could return 0 length data, |
| 13 | + but it is never checked before dereferencing the data pointer. |
| 14 | + - fixed with dc4a1f2617867eb3b2c170ec51dd2bbae0212480 |
| 15 | +- [cac_is_cert](https://github.com/OpenSC/OpenSC/blob/23dcca082fa35eb454f8a2add163dfd506eab434/src/libopensc/card-cac.c#L237) |
| 16 | + - The object comparison could use some of the unitialized object members. |
| 17 | + - fixed with 61985ce021b386b11a29eb4d27c6a7ae00e8e2a6 |
| 18 | +- [cac_read_binary](https://github.com/OpenSC/OpenSC/blob/23dcca082fa35eb454f8a2add163dfd506eab434/src/libopensc/card-cac.c#L526) |
| 19 | + - the function is merging the TagLength file with the Value files. |
| 20 | + Inconsistencies are ignored, but the resulting object has full |
| 21 | + length even if some part is uninitialized, which can be used later |
| 22 | + on by the driver. |
| 23 | + - fixed with 35b2f54212db0d6adcc337e456ddc728eeabd044 |
| 24 | +- [cac_get_properties](https://github.com/OpenSC/OpenSC/blob/23dcca082fa35eb454f8a2add163dfd506eab434/src/libopensc/card-cac.c#L932) |
| 25 | + - the function might not be setting all the members of the properties |
| 26 | + structure the caller expects. Initializing it before invocation |
| 27 | + avoids this problem. |
| 28 | + - fixed with 5b0cda30e8226c41c69735f95234d98eda1be550 |
| 29 | +- [esteid_select_file](https://github.com/OpenSC/OpenSC/blob/23dcca082fa35eb454f8a2add163dfd506eab434/src/libopensc/card-esteid2018.c#L122) |
| 30 | + - the select file assumes the APDU returns the whole requested length, |
| 31 | + which might not be the case. When card returns less data, |
| 32 | + the uninitialized data is attempted to get parsed as FCI structure. |
| 33 | + - fixed with bd8687b40f6948278ec115aa7a19ee7274760ce0 |
| 34 | +- [gemsafe_process_fci](https://github.com/OpenSC/OpenSC/blob/23dcca082fa35eb454f8a2add163dfd506eab434/src/libopensc/card-gemsafeV1.c#L350) |
| 35 | + - The `sc_asn1_find_tag()` could return 0-lenght value, which is processed |
| 36 | + without checking for the length. |
| 37 | + - fixed with 267111f2e3b766e5ad985105cd1a3416d569ff89 |
| 38 | +- [iasecc_emulate_fcp](https://github.com/OpenSC/OpenSC/blob/23dcca082fa35eb454f8a2add163dfd506eab434/src/libopensc/card-iasecc.c#L862) |
| 39 | + - emulating the FCP object could result in too long resplen in the emulated |
| 40 | + APDU returned to a caller, which might read uninitialized data from there. |
| 41 | + - fixed with ab568f0a420931d5372bc8657f4024ca6d0e3285 |
| 42 | +- [iasecc_se_parse](https://github.com/OpenSC/OpenSC/blob/23dcca082fa35eb454f8a2add163dfd506eab434/src/libopensc/iasecc-sdo.c#L328) |
| 43 | + - the function could use uninitialized memory behind the buffer bounds |
| 44 | + without proper check. |
| 45 | + - fixed with 7aafe6f8c4a962d8ee9208a62272b6b38d6db9f6, a89dff3271da2eccd834553a4c0dfb7c543657c5 |
| 46 | +- [get_cert_len](https://github.com/OpenSC/OpenSC/blob/23dcca082fa35eb454f8a2add163dfd506eab434/src/libopensc/pkcs15-atrust-acos.c#L81) |
| 47 | + - incorrect return value check could cause use of uninitialized data |
| 48 | + - fixed with 7e3dcae1d14e898dfed00ce8aa1d1bfeaee7c936 |
| 49 | +- [coolkey_get_attribute_bytes_alloc](https://github.com/OpenSC/OpenSC/blob/23dcca082fa35eb454f8a2add163dfd506eab434/src/libopensc/pkcs15-coolkey.c#L212) |
| 50 | + - Unchecked size of return buffer could cause zero-length allocations |
| 51 | + and following code dereferencing this variable. |
| 52 | + - fixed with 40fbddc46e026618b6a3d0a03e62adc1fb5ca956 |
| 53 | +- [sc_pkcs15emu_openpgp_init](https://github.com/OpenSC/OpenSC/blob/23dcca082fa35eb454f8a2add163dfd506eab434/src/libopensc/pkcs15-openpgp.c#L318) |
| 54 | + - uninitilized variable could cause comparison against this value, |
| 55 | + with unexpected consequences. |
| 56 | + - fixed with 29122ae779fa8ecb201b0c0b3bdad058b9540262 |
| 57 | +- [sc_pkcs15_pubkey_from_spki_fields](https://github.com/OpenSC/OpenSC/blob/23dcca082fa35eb454f8a2add163dfd506eab434/src/libopensc/pkcs15-pubkey.c#L1342) |
| 58 | + - the callback function could be called with 0-length buffer, |
| 59 | + resulting in 0-lenght allocations and dereferencing of this value. |
| 60 | + - fixed with 7000dee0eb7d35246b5e180b39bb4e03b11f1c47 |
| 61 | +- [get_cert_len](https://github.com/OpenSC/OpenSC/blob/23dcca082fa35eb454f8a2add163dfd506eab434/src/libopensc/pkcs15-starcert.c#L91) |
| 62 | + - the function accesses the uninitialized memory when the card returns |
| 63 | + too short response. |
| 64 | + - fixed with 7e3dcae1d14e898dfed00ce8aa1d1bfeaee7c936 |
| 65 | +- [insert_cert](https://github.com/OpenSC/OpenSC/blob/23dcca082fa35eb454f8a2add163dfd506eab434/src/libopensc/pkcs15-tcos.c#L81) |
| 66 | + - Parsing of the returned buffer could use uninitialized memory when |
| 67 | + the card responses with too short data. |
| 68 | + - fixed with 263d29e2f8baf33f329849c82ba9c08ec45f1ad7 |
| 69 | + |
| 70 | +There are few more cases, that are accessible only during the card |
| 71 | +enrollment/initialization and therefore they are not exploitable on generic |
| 72 | +end-user system: |
| 73 | + |
| 74 | +- [entersafe_init_card](https://github.com/OpenSC/OpenSC/blob/23dcca082fa35eb454f8a2add163dfd506eab434/src/pkcs15init/pkcs15-entersafe.c#L80) |
| 75 | + - Uninitialized members could be used in the APDU, |
| 76 | + resulting in unexpected behavior. |
| 77 | + - fixed with f29e937aa77ad000cd65cc1806972203bd3b0f43 |
| 78 | +- [cosm_generate_key](https://github.com/OpenSC/OpenSC/blob/23dcca082fa35eb454f8a2add163dfd506eab434/src/pkcs15init/pkcs15-oberthur.c#L692) |
| 79 | + - Uninitialized member `pubkey->u.rsa.modulus.len` is used later |
| 80 | + in the code execution. |
| 81 | + - fixed with a998551ca19f2bd0e664c59d415675c062e3920b |
| 82 | +- [build_argv](https://github.com/OpenSC/OpenSC/blob/23dcca082fa35eb454f8a2add163dfd506eab434/src/pkcs15init/profile.c#L2090) |
| 83 | + - Ignoring return value of `get_inner_word()a could cause use |
| 84 | + of uninitilizad variables later. |
| 85 | + - fixed with c1d3ebb130f909eff2aef1924f28f3d4c04786a6 |
| 86 | + |
| 87 | +Affected versions: all before 0.27.0 |
| 88 | + |
| 89 | +Originally reported by Matteo Marini (Sapienza University of Rome). |
| 90 | +Some of the issues were also reported independently by Aldo Ristori via OSS-Fuzz. |
| 91 | +Patches provided by Jakub Jelen. |
| 92 | + |
| 93 | +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