Wednesday, December 02, 2026

dovecot-pigeonhole, fix CVE-2026-42007 (Sieve editheader use-after-free)

To: ports@openbsd.org Cc: Brad Smith <brad@comstyle.com> Subject: dovecot-pigeonhole, fix CVE-2026-42007 (Sieve editheader use-after-free) Dovecot Security Advisory 3/2026 (oss-security, 2026-08-28) lists CVE-2026-42007 (CVSS 9.1): an authenticated user can use a Sieve script with the editheader extension to trigger a use-after-free in the mail editing code, and to leak heap memory into the delivered mail, during delivery. CE is fixed only in 2.4.5; there is no 2.3 community release, so 0.5.21.1 in ports is still affected. Debian backported the fix to their 2.3 package (DLA-4873-1). The attached diff (sent as an attachment because my mailer mangles inline diffs) adds the two upstream pigeonhole commits as a patch: 69bac9cd (reset header_index first pointers before rebuilding the index, the use-after-free) and a44ba381 (copy the full header size instead of i_strndup(), the NUL-truncation over-read). Both apply to 0.5.21.1 with small offsets only. The upstream test-only commit cd9870e and the new regression .svtest files are not included, as they need Makefile.am changes. Tested on 8.0/amd64 with the OPENBSD_8_0 ports tree: - the upstream regression test deleteheader-snapshot.svtest segfaults with the current package and passes with this patch; - the full pigeonhole testsuite (make test) passes; - the package builds, installs over 0.5.21.1v1 and runs with dovecot 2.3.21.1p3v0 (Sieve and editheader delivery work as before). The same diff applies to -current. Could it also go to 8.0-stable? ok? Index: Makefile =================================================================== RCS file: /cvs/ports/mail/dovecot-pigeonhole/Makefile,v diff -u -p -u -p -r1.88 Makefile --- Makefile 16 Aug 2024 10:57:26 -0000 1.88 +++ Makefile 2 Dec 2026 09:47:03 -0000 @@ -6,6 +6,7 @@ V_DOVECOT= 2.3 DISTNAME= dovecot-${V_DOVECOT}-pigeonhole-${V_SIEVE} PKGNAME= dovecot-pigeonhole-${V_SIEVE} EPOCH= 1 +REVISION= 0 CATEGORIES= mail SITES= ${HOMEPAGE}releases/${V_DOVECOT}/ DPB_PROPERTIES= parallel Index: patches/patch-src_lib-sieve_util_edit-mail_c =================================================================== RCS file: patches/patch-src_lib-sieve_util_edit-mail_c diff -N patches/patch-src_lib-sieve_util_edit-mail_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_lib-sieve_util_edit-mail_c 2 Dec 2026 09:47:03 -0000 @@ -0,0 +1,59 @@ +Fix CVE-2026-42007 (Dovecot Security Advisory 3/2026, Sieve editheader +use-after-free and heap over-read) + +From 69bac9cd6d4ac09100ee50c98052be1437f1da29 Mon Sep 17 00:00:00 2001 +From: Timo Sirainen <timo.sirainen@open-xchange.com> +Date: Tue, 14 Apr 2026 12:58:08 +0200 +Subject: [PATCH] lib-sieve: util: edit-mail - Fix writing to freed memory + +From a44ba381619a06416ce3f34eae9765de46ece5d9 Mon Sep 17 00:00:00 2001 +From: Timo Sirainen <timo.sirainen@open-xchange.com> +Date: Fri, 1 May 2026 06:28:33 +0000 +Subject: [PATCH] lib-sieve: edit_mail_headers_parse() - Fix info leak via + NUL-truncated header copy + +Index: src/lib-sieve/util/edit-mail.c +--- src/lib-sieve/util/edit-mail.c.orig ++++ src/lib-sieve/util/edit-mail.c +@@ -550,8 +550,9 @@ edit_mail_header_field_create(struct edit_mail *edmail + &field->body_offset); + + /* Copy to new field */ +- field->data = i_strndup(str_data(data), str_len(data)); + field->size = str_len(data); ++ field->data = i_malloc(field->size + 1); ++ memcpy(field->data, str_data(data), field->size); + field->virtual_size = (edmail->crlf ? + field->size : field->size + lines); + field->lines = lines; +@@ -828,8 +829,9 @@ static int edit_mail_headers_parse(struct edit_mail *e + + field->size = str_len(hdr_data); + field->virtual_size = field->size + vsize_diff; +- field->data = i_strndup(str_data(hdr_data), +- field->size); ++ field->data = i_malloc(field->size + 1); ++ memcpy(field->data, str_data(hdr_data), ++ field->size); + field->offset = offset; + field->lines = lines; + +@@ -887,7 +889,17 @@ static int edit_mail_headers_parse(struct edit_mail *e + } + } + +- /* Rebuild header index */ ++ /* Rebuild header index. Reset first pointers before rebuilding so that ++ the actual first occurrence in the final list is used. Without this, ++ a snapshot's pre-set first pointer may refer to an appended field ++ that sits later in the list than a parsed field with the same header, ++ causing deleteheader to miss the parsed fields while still freeing ++ the header_index — leaving stale field_idx->header pointers. */ ++ struct _header_index *hidx = edmail->headers_head; ++ while (hidx != NULL) { ++ hidx->first = NULL; ++ hidx = hidx->next; ++ } + current = edmail->header_fields_head; + while (current != NULL) { + if (current->header->first == NULL)

No comments:

Post a Comment