From 6e2e3ca269ae06cea59d000f50d7bcbc2012c55f Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Fri, 14 Aug 2026 14:15:50 +0200 Subject: [PATCH] Authenticate before IMPORT slot parsing Signed-off-by: Pol Henarejos --- src/openpgp/cmd_import_data.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/openpgp/cmd_import_data.c b/src/openpgp/cmd_import_data.c index a6f2b64..4b5fa27 100644 --- a/src/openpgp/cmd_import_data.c +++ b/src/openpgp/cmd_import_data.c @@ -46,7 +46,6 @@ static bool tag_len(uint8_t **data, const uint8_t *end, uint16_t *len_out) { } int cmd_import_data(void) { - file_t *ef = NULL; uint16_t fid = 0x0; if (P1(apdu) != 0x3F || P2(apdu) != 0xFF) { return SW_WRONG_P1P2(); @@ -54,6 +53,9 @@ int cmd_import_data(void) { if (apdu.nc < 5) { return SW_WRONG_LENGTH(); } + if (!has_pw3) { + return SW_SECURITY_STATUS_NOT_SATISFIED(); + } uint8_t *start = apdu.data; uint8_t *apdu_end = apdu.data + apdu.nc; if (*start++ != 0x4D) { @@ -83,12 +85,6 @@ int cmd_import_data(void) { return SW_WRONG_DATA(); } start++; - if (!(ef = file_search_by_fid(fid, NULL, SPECIFY_EF))) { - return SW_REFERENCE_NOT_FOUND(); - } - if (!file_authenticate_action(ef, ACL_OP_UPDATE_ERASE)) { - return SW_SECURITY_STATUS_NOT_SATISFIED(); - } if (start >= outer_end || (size_t)(outer_end - start) < (size_t)*start + 1u) { return SW_WRONG_DATA(); }