opensc: fix CVE-2024-1454

CVE-2024-1454:
The use-after-free vulnerability was found in the AuthentIC driver in OpenSC packages,
occuring in the card enrolment process using pkcs15-init when a user or administrator
enrols or modifies cards. An attacker must have physical access to the computer system
and requires a crafted USB device or smart card to present the system with specially
crafted responses to the APDUs, which are considered high complexity and low severity.
This manipulation can allow for compromised card management operations during enrolment.

Reference:
[https://nvd.nist.gov/vuln/detail/CVE-2024-1454]

Upstream patches:
[https://github.com/OpenSC/OpenSC/commit/5835f0d4f6c033bd58806d33fa546908d39825c9]

Signed-off-by: Zhang Peng <peng.zhang1.cn@windriver.com>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
This commit is contained in:
Zhang Peng
2025-01-15 15:24:21 +08:00
committed by Armin Kuster
parent 291fc3e7fc
commit 7e91b406fa
2 changed files with 38 additions and 0 deletions
@@ -0,0 +1,37 @@
From 5835f0d4f6c033bd58806d33fa546908d39825c9 Mon Sep 17 00:00:00 2001
From: Jakub Jelen <jjelen@redhat.com>
Date: Mon, 18 Dec 2023 11:09:50 +0100
Subject: [PATCH] authentic: Avoid use after free
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=64898
CVE: CVE-2024-1454
Upstream-Status: Backport [https://github.com/OpenSC/OpenSC/commit/5835f0d4f6c033bd58806d33fa546908d39825c9]
The original patch is adjusted to fit for the current version.
Signed-off-by: Zhang Peng <peng.zhang1.cn@windriver.com>
---
src/pkcs15init/pkcs15-authentic.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/pkcs15init/pkcs15-authentic.c b/src/pkcs15init/pkcs15-authentic.c
index c6894dd37..adedd0a04 100644
--- a/src/pkcs15init/pkcs15-authentic.c
+++ b/src/pkcs15init/pkcs15-authentic.c
@@ -858,7 +858,10 @@ authentic_emu_update_tokeninfo(struct sc_profile *profile, struct sc_pkcs15_card
rv = sc_select_file(p15card->card, &path, &file);
if (!rv) {
rv = sc_get_challenge(p15card->card, buffer, sizeof(buffer));
- LOG_TEST_RET(ctx, rv, "Get challenge error");
+ if (rv < 0) {
+ sc_file_free(file);
+ LOG_TEST_RET(ctx, rv, "Get challenge error");
+ }
len = file->size > sizeof(buffer) ? sizeof(buffer) : file->size;
rv = sc_update_binary(p15card->card, 0, buffer, len, 0);
--
2.34.1
@@ -23,6 +23,7 @@ SRC_URI = "git://github.com/OpenSC/OpenSC;branch=master;protocol=https \
file://CVE-2023-40661-5.patch \
file://CVE-2023-40661-6.patch \
file://CVE-2023-40661-7.patch \
file://CVE-2024-1454.patch \
"
# CVE-2021-34193 is a duplicate CVE covering the 5 individual