Bugfixes for the SymCrypt provider#165
Conversation
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pre-existing issue in touched code: p_scossl_rsa_cipher_dupctx() shallow-copies the SCOSSL_RSA_CIPHER_CTX struct via OPENSSL_memdup, which includes the pbLabel pointer. Both the original and duplicate contexts will call OPENSSL_free(ctx->pbLabel) on cleanup — double-free / use-after-free. Since this file is already being touched for the outlen hardening, consider deep-copying pbLabel in dupctx.
| return SCOSSL_FAILURE; | ||
| } | ||
|
|
||
| ctx->initialized = TRUE; |
There was a problem hiding this comment.
Suggestion (nit): Consider setting ctx->initialized = FALSE at the entry of the if (pbKey != NULL) block (around line 345), before attempting key expansion.
Currently, if a previously-initialized context calls init with a new key and expandKeyFunc fails (early return at line 367), ctx->initialized remains TRUE from the prior successful init. Subsequent update/final calls would then silently operate with the stale old expanded key rather than failing with the ""not initialized"" error.
Poisoning at entry and setting TRUE only on success (as you already do at this line) would close that window.
This PR fixes a number of minor bugs and behavior issues with the SymCrypt provider. These bugs are either normally not triggerable through the EVP layer or normal calling patterns, or impact uncommonly used functions.
OSSL_CIPHER_PARAM_TLS_MAC_SIZEp_scossl_dh_keymgmt_dup_key_ctxwould allocate an incorrectly sized buffer when copying a context using a custom group and with no key set yet.Thanks @vcsjones for discovering these!