Skip to content

Commit

Permalink
Add check for slot_id 0xFF to prevent out-of-bond access.
Browse files Browse the repository at this point in the history
Signed-off-by: Jiewen Yao <[email protected]>
  • Loading branch information
jyao1 committed Aug 20, 2024
1 parent dd2b624 commit 8b95512
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ libspdm_return_t libspdm_get_encap_response_challenge_auth(
}

if ((spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_13) &&
context->connection_info.multi_key_conn_req) {
context->connection_info.multi_key_conn_req &&
(slot_id != 0xFF)) {
if ((context->local_context.local_key_usage_bit_mask[slot_id] &
SPDM_KEY_USAGE_BIT_MASK_CHALLENGE_USE) == 0) {
return libspdm_generate_encap_error_response(
Expand Down
3 changes: 2 additions & 1 deletion library/spdm_requester_lib/libspdm_req_key_exchange.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,8 @@ static libspdm_return_t libspdm_try_send_receive_key_exchange(
goto receive_done;
}
if ((spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_13) &&
spdm_context->connection_info.multi_key_conn_req) {
spdm_context->connection_info.multi_key_conn_req &&
(*req_slot_id_param != 0xf)) {
if ((spdm_context->local_context.local_key_usage_bit_mask[*req_slot_id_param] &
SPDM_KEY_USAGE_BIT_MASK_KEY_EX_USE) == 0) {
libspdm_secured_message_dhe_free(
Expand Down
3 changes: 2 additions & 1 deletion library/spdm_responder_lib/libspdm_rsp_challenge_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ libspdm_return_t libspdm_get_response_challenge_auth(libspdm_context_t *spdm_con
}

if ((spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_13) &&
spdm_context->connection_info.multi_key_conn_rsp) {
spdm_context->connection_info.multi_key_conn_rsp &&
(slot_id != 0xFF)) {
if ((spdm_context->local_context.local_key_usage_bit_mask[slot_id] &
SPDM_KEY_USAGE_BIT_MASK_CHALLENGE_USE) == 0) {
return libspdm_generate_error_response(
Expand Down
3 changes: 2 additions & 1 deletion library/spdm_responder_lib/libspdm_rsp_key_exchange.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ libspdm_return_t libspdm_get_response_key_exchange(libspdm_context_t *spdm_conte
}

if ((spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_13) &&
spdm_context->connection_info.multi_key_conn_rsp) {
spdm_context->connection_info.multi_key_conn_rsp &&
(slot_id != 0xff)) {
if ((spdm_context->local_context.local_key_usage_bit_mask[slot_id] &
SPDM_KEY_USAGE_BIT_MASK_KEY_EX_USE) == 0) {
return libspdm_generate_error_response(
Expand Down
3 changes: 2 additions & 1 deletion library/spdm_responder_lib/libspdm_rsp_measurements.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,8 @@ libspdm_return_t libspdm_get_response_measurements(libspdm_context_t *spdm_conte
}

if ((spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_13) &&
spdm_context->connection_info.multi_key_conn_rsp) {
spdm_context->connection_info.multi_key_conn_rsp &&
(slot_id_param != 0xF)) {
if ((spdm_context->local_context.local_key_usage_bit_mask[slot_id_param] &
SPDM_KEY_USAGE_BIT_MASK_MEASUREMENT_USE) == 0) {
return libspdm_generate_error_response(
Expand Down

0 comments on commit 8b95512

Please sign in to comment.