Skip to content

Clear DIGESTS and RESPOND_IF_READY state in reset_context - #4199

Merged
jyao1 merged 1 commit into
DMTF:mainfrom
v1rtu3x:reset-context-clear-connection-state
Oct 19, 2026
Merged

jyao1 merged 1 commit into
DMTF:mainfrom
v1rtu3x:reset-context-clear-connection-state

Conversation

@v1rtu3x

@v1rtu3x v1rtu3x commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Fixes #4182.

libspdm_reset_context() left two pieces of the previous connection behind:

  • the peer's DIGESTS results — peer_provisioned_slot_mask, peer_supported_slot_mask, peer_key_pair_id[], peer_cert_info[], peer_key_usage_bit_mask[]
  • the RESPOND_IF_READY state — the cached request bytes stayed in the scratch buffer in plaintext even for session-encrypted requests, its session ID fields were left set, and error_data was never cleared (it sits outside the LIBSPDM_RESPOND_IF_READY_SUPPORT guard)

Zero the DIGESTS fields, erase the cached request across its whole scratch buffer capacity, reset its session ID fields, and clear error_data unconditionally.

The new test_spdm_common case81 fills all of this state and verifies reset_context clears it, byte by byte for the cached request buffer. It compiles and passes under both LIBSPDM_RESPOND_IF_READY_SUPPORT=0 and =1.

Tested locally (GCC 14.2.0, x64, Debug): full battery (requester, responder, common, spdm_crypt, crypt, secured_message) with mbedtls and openssl, plus the CI feature matrix (all capabilities off / RECORD_TRANSCRIPT 0+FIPS 0 / RECORD_TRANSCRIPT 1+FIPS 1 incl. test_spdm_fips). The case fails before the fix (0x5 != 0) and passes after. format_nix.sh --check, check_encode.sh, check_copyright_date.sh, check_commit_message.sh pass.

Happy to adjust anything — thanks for maintaining libspdm!

@steven-bellock steven-bellock changed the title Clear DIGESTS and RESPOND_IF_READY state in reset_context Clear DIGESTS and RESPOND_IF_READY state in reset_context Oct 17, 2026
Comment thread library/spdm_common_lib/libspdm_com_context_data.c Outdated
libspdm_reset_context() left two pieces of the previous connection
behind: the peer's DIGESTS results (slot masks, key_pair_id,
cert_info, key_usage_bit_mask) and the RESPOND_IF_READY state, whose
cached request bytes stayed in the scratch buffer in plaintext even
for session-encrypted requests. error_data was never cleared, and it
sits outside the LIBSPDM_RESPOND_IF_READY_SUPPORT guard.

Zero the DIGESTS fields, erase the cached request across its whole
scratch buffer capacity, reset its session ID fields, and clear
error_data unconditionally. The new test_spdm_common case81 fills all
of this state and verifies reset_context clears it.

Fixes DMTF#4182

Assisted-by: Kimi:K2.8
Signed-off-by: Mark Tamas <marktamas28@gmail.com>
@v1rtu3x
v1rtu3x force-pushed the reset-context-clear-connection-state branch from e53b619 to a864acc Compare October 18, 2026 07:57
@jyao1
jyao1 merged commit b763c37 into DMTF:main Oct 19, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

libspdm_reset_context() leaves DIGESTS and RESPOND_IF_READY state behind

3 participants