Skip to content

fix: correct duplicate NULL check in oqsx_get_hybrid_params() (GHSA-mqwg-cg22-g8r8)#767

Open
iiviel wants to merge 2 commits intoopen-quantum-safe:mainfrom
iiviel:fix/oqs-kmgmt-copypaste-null-check
Open

fix: correct duplicate NULL check in oqsx_get_hybrid_params() (GHSA-mqwg-cg22-g8r8)#767
iiviel wants to merge 2 commits intoopen-quantum-safe:mainfrom
iiviel:fix/oqs-kmgmt-copypaste-null-check

Conversation

@iiviel
Copy link
Copy Markdown

@iiviel iiviel commented Apr 11, 2026

Fixes the copy-paste NULL check bug at oqs_kmgmt.c:412. Replaces duplicate key->comp_privkey != NULL check with correct key->privkey != NULL check. Submitted per request in GHSA-mqwg-cg22-g8r8.

iiviel added 2 commits April 11, 2026 13:55
…free

oqs_sig_dupctx() performs a shallow struct copy (*dstctx = *srcctx) but
never deep-copies the heap-allocated `signature` field (added under the
OPENSSL_VERSION_PREREQ(3,4) guard). Both srcctx and dstctx share the
same pointer, and oqs_sig_freectx() frees it unconditionally, causing a
double-free when both contexts are freed.

Fix:
1. NULL out dstctx->signature and dstctx->siglen immediately after the
   shallow copy, alongside the existing NULLing of sig, md, mdctx.
   This prevents the error path (goto err → oqs_sig_freectx) from
   freeing srcctx's allocation.
2. Add an OPENSSL_memdup deep-copy of srcctx->signature before the
   return, with goto err on allocation failure.

GHSA-2gh6-p878-65cq

Signed-off-by: Eva Crystal <0xiviel@gmail.com>
…qwg-cg22-g8r8)

Replace duplicate comp_privkey != NULL check with correct privkey != NULL
check at oqs_kmgmt.c:412. The copy-paste error allowed the code to proceed
with a dangling comp_privkey pointer when privkey had been freed, causing
a use-after-free (CWE-416) readable via EVP_PKEY_get_params().

Signed-off-by: Eva Crystal <0xiviel@gmail.com>
@iiviel iiviel force-pushed the fix/oqs-kmgmt-copypaste-null-check branch from 4009d01 to 222e765 Compare April 11, 2026 01:56
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.

1 participant