Skip to content

Commit 6419ac9

Browse files
[AUTO-CHERRYPICK] [Medium] opensc: Fix CVE-2023-40660 and CVE-2024-1454 - branch main (#12661)
Co-authored-by: Sreenivasulu Malavathula (HCL Technologies Ltd) <v-smalavathu@microsoft.com>
1 parent dee5ac7 commit 6419ac9

3 files changed

Lines changed: 93 additions & 1 deletion

File tree

SPECS/opensc/CVE-2023-40660.patch

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
From 744f2647b999d0c96243acdffd95f1b7b6c6dfa0 Mon Sep 17 00:00:00 2001
2+
From: Sreenivasulu Malavathula <v-smalavathu@microsoft.com>
3+
Date: Sun, 23 Feb 2025 19:17:33 -0600
4+
Subject: [PATCH] Address CVE-2023-40660
5+
6+
---
7+
src/libopensc/card-authentic.c | 11 +++++++++++
8+
src/libopensc/pkcs15-pin.c | 13 -------------
9+
2 files changed, 11 insertions(+), 13 deletions(-)
10+
11+
diff --git a/src/libopensc/card-authentic.c b/src/libopensc/card-authentic.c
12+
index 563210d..344c09c 100644
13+
--- a/src/libopensc/card-authentic.c
14+
+++ b/src/libopensc/card-authentic.c
15+
@@ -2311,6 +2311,17 @@ authentic_sm_get_wrapped_apdu(struct sc_card *card, struct sc_apdu *plain, struc
16+
}
17+
#endif
18+
19+
+int authentic_logout(sc_card_t *card)
20+
+{
21+
+ int r = SC_ERROR_NOT_SUPPORTED;
22+
+
23+
+ if (card->type == SC_CARD_TYPE_OBERTHUR_AUTHENTIC_3_2) {
24+
+ r = authentic_select_aid(card, aid_AuthentIC_3_2, sizeof(aid_AuthentIC_3_2), NULL, NULL);
25+
+ }
26+
+
27+
+ return r;
28+
+}
29+
+
30+
static struct sc_card_driver *
31+
sc_get_driver(void)
32+
{
33+
diff --git a/src/libopensc/pkcs15-pin.c b/src/libopensc/pkcs15-pin.c
34+
index 48e16fd..2402675 100644
35+
--- a/src/libopensc/pkcs15-pin.c
36+
+++ b/src/libopensc/pkcs15-pin.c
37+
@@ -307,19 +307,6 @@ sc_pkcs15_verify_pin(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *pi
38+
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_PIN_REFERENCE);
39+
auth_info = (struct sc_pkcs15_auth_info *)pin_obj->data;
40+
41+
- /*
42+
- * if pin cache is disabled, we can get here with no PIN data.
43+
- * in this case, to avoid error or unnecessary pin prompting on pinpad,
44+
- * check if the PIN has been already verified and the access condition
45+
- * is still open on card.
46+
- */
47+
- if (pinlen == 0) {
48+
- r = sc_pkcs15_get_pin_info(p15card, pin_obj);
49+
-
50+
- if (r == SC_SUCCESS && auth_info->logged_in == SC_PIN_STATE_LOGGED_IN)
51+
- LOG_FUNC_RETURN(ctx, r);
52+
- }
53+
-
54+
r = _validate_pin(p15card, auth_info, pinlen);
55+
56+
if (r)
57+
--
58+
2.45.2
59+

SPECS/opensc/CVE-2024-1454.patch

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
From 4d1fbfdce97b44bb4ffb991bbc481da5056c1bfe Mon Sep 17 00:00:00 2001
2+
From: Sreenivasulu Malavathula <v-smalavathu@microsoft.com>
3+
Date: Sun, 23 Feb 2025 19:04:16 -0600
4+
Subject: [PATCH] Address CVE-2024-1454
5+
6+
---
7+
src/pkcs15init/pkcs15-authentic.c | 5 ++++-
8+
1 file changed, 4 insertions(+), 1 deletion(-)
9+
10+
diff --git a/src/pkcs15init/pkcs15-authentic.c b/src/pkcs15init/pkcs15-authentic.c
11+
index c6894dd..adedd0a 100644
12+
--- a/src/pkcs15init/pkcs15-authentic.c
13+
+++ b/src/pkcs15init/pkcs15-authentic.c
14+
@@ -858,7 +858,10 @@ authentic_emu_update_tokeninfo(struct sc_profile *profile, struct sc_pkcs15_card
15+
rv = sc_select_file(p15card->card, &path, &file);
16+
if (!rv) {
17+
rv = sc_get_challenge(p15card->card, buffer, sizeof(buffer));
18+
- LOG_TEST_RET(ctx, rv, "Get challenge error");
19+
+ if (rv < 0) {
20+
+ sc_file_free(file);
21+
+ LOG_TEST_RET(ctx, rv, "Get challenge error");
22+
+ }
23+
24+
len = file->size > sizeof(buffer) ? sizeof(buffer) : file->size;
25+
rv = sc_update_binary(p15card->card, 0, buffer, len, 0);
26+
--
27+
2.45.2
28+

SPECS/opensc/opensc.spec

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Summary: Smart card library and applications
44
Name: opensc
55
Version: 0.23.0
6-
Release: 3%{?dist}
6+
Release: 4%{?dist}
77
License: LGPLv2+
88
Vendor: Microsoft Corporation
99
Distribution: Mariner
@@ -13,6 +13,8 @@ Source1: opensc.module
1313
Patch1: opensc-0.23.0-pinpad.patch
1414
Patch2: CVE-2023-4535.patch
1515
Patch3: CVE-2023-5992.patch
16+
Patch4: CVE-2024-1454.patch
17+
Patch5: CVE-2023-40660.patch
1618
BuildRequires: autoconf
1719
BuildRequires: automake
1820
BuildRequires: bash-completion
@@ -142,6 +144,9 @@ rm %{buildroot}%{_mandir}/man1/opensc-notify.1*
142144
%{_mandir}/man5/*
143145

144146
%changelog
147+
* Tue Feb 25 2025 Sreeniavsulu Malavathula <v-smalavathu@microsoft.com> - 0.23.0-4
148+
- Patch to fix CVE-2024-1454, CVE-2023-40660
149+
145150
* Fri Feb 21 2025 Sindhu Karri <lakarri@microsoft.com> - 0.23.0-3
146151
- Fix CVE-2023-5992
147152

0 commit comments

Comments
 (0)