From: Tomas Mraz Date: Wed, 21 Jan 2026 18:11:30 +0000 (+0100) Subject: rsa_enc.c: Properly duplicate the oaep_label member X-Git-Tag: openssl-3.0.19~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=923213c68032dce9f98e90758edb9c5f87cd2400;p=thirdparty%2Fopenssl.git rsa_enc.c: Properly duplicate the oaep_label member Otherwise UAF and doublefree appears when the duplicate is freed. Reported by Tomas Dulka and Stanislav Fort (Aisle Research) Reviewed-by: Richard Levitte Reviewed-by: Eugene Syromiatnikov Reviewed-by: Paul Dale MergeDate: Fri Jan 23 10:40:31 2026 (Merged from https://github.com/openssl/openssl/pull/29707) --- diff --git a/providers/implementations/asymciphers/rsa_enc.c b/providers/implementations/asymciphers/rsa_enc.c index 6a82f882176..6cbd01cbc5c 100644 --- a/providers/implementations/asymciphers/rsa_enc.c +++ b/providers/implementations/asymciphers/rsa_enc.c @@ -332,6 +332,12 @@ static void *rsa_dupctx(void *vprsactx) return NULL; } + if (dstctx->oaep_label != NULL + && (dstctx->oaep_label = OPENSSL_memdup(dstctx->oaep_label, dstctx->oaep_labellen)) == NULL) { + rsa_freectx(dstctx); + return NULL; + } + return dstctx; }