package/exim: add upstream security fixes for CVE-2022-3559
PATCH 1/2 package/exim: add upstream security fixes for CVE-2022-3559
Fixes CVE-2022-3559: A vulnerability was found in Exim and classified as problematic. This issue affects some unknown processing of the component Regex Handler. The manipulation leads to use after free. The name of the patch is 4e9ed49f8f12eb331b29bd5b6dc3693c520fddc2. It is recommended to apply a patch to fix this issue. The identifier VDB-211073 was assigned to this vulnerability.
The upstream patch does not apply to 4.96, so use the backported patches from Debian. Amazingly, the patch needs 3 additional patches to unbreak builds without "WITH_CONTENT_SCAN" (default in Buildroot), so add those as well.
--- ...Fix-regex-n-use-after-free.-Bug-2915.patch | 173 ++++++++++++++++++ ...0007-Fix-non-WITH_CONTENT_SCAN-build.patch | 61 ++++++ ...08-Fix-non-WITH_CONTENT_SCAN-build-2.patch | 139 ++++++++++++++ ...09-Fix-non-WITH_CONTENT_SCAN-build-3.patch | 49 +++++ package/exim/exim.mk | 3 + 5 files changed, 425 insertions(+) create mode 100644 package/exim/0006-Fix-regex-n-use-after-free.-Bug-2915.patch create mode 100644 package/exim/0007-Fix-non-WITH_CONTENT_SCAN-build.patch create mode 100644 package/exim/0008-Fix-non-WITH_CONTENT_SCAN-build-2.patch create mode 100644 package/exim/0009-Fix-non-WITH_CONTENT_SCAN-build-3.patch
package/exim/0006-Fix-regex-n-use-after-free.-Bug-2915.patch new file +173 -0
@@ -0,0 +1,173 @@ +From 4e9ed49f8f12eb331b29bd5b6dc3693c520fddc2 Mon Sep 17 00:00:00 2001 +From: Jeremy Harris <[email protected]> +Date: Wed, 31 Aug 2022 15:37:40 +0100 +Subject: [PATCH] Fix $regex<n> use-after-free. Bug 2915 + +[Upstream: https://sources.debian.org/data/main/e/exim4/4.96-9/debian/patches/75_08-Fix-regex-n-use-after-free.-Bug-2915.patch] +[Peter: drop Changelog hunk] +Signed-off-by: Peter Korsgaard <[email protected]> +--- + src/exim.c | 4 +--- + src/expand.c | 2 +- + src/functions.h | 1 + + src/globals.c | 2 +- + src/regex.c | 29 ++++++++++++++++++----------- + src/smtp_in.c | 2 ++ + test/confs/4002 | 10 ++++++++++ + test/mail/4002.userx | 7 +++++++ + test/scripts/4000-scanning/4002 | 7 +++++++ + 9 files changed, 53 insertions(+), 17 deletions(-) + +--- a/src/exim.c ++++ b/src/exim.c +@@ -1999,12 +1999,10 @@ + + regex_whitelisted_macro = + regex_must_compile(US"^[A-Za-z0-9_/.-]*$", FALSE, TRUE); + #endif + +-for (i = 0; i < REGEX_VARS; i++) regex_vars[i] = NULL; +- + /* If the program is called as "mailq" treat it as equivalent to "exim -bp"; + this seems to be a generally accepted convention, since one finds symbolic + links called "mailq" in standard OS configurations. */ + + if ((namelen == 5 && Ustrcmp(argv[0], "mailq") == 0) || +@@ -6082,11 +6080,11 @@ + callout_address = NULL; + sending_ip_address = NULL; + deliver_localpart_data = deliver_domain_data = + recipient_data = sender_data = NULL; + acl_var_m = NULL; +- for(int i = 0; i < REGEX_VARS; i++) regex_vars[i] = NULL; ++ regex_vars_clear(); + + store_reset(reset_point); + } + + exim_exit(EXIT_SUCCESS); /* Never returns */ +--- a/src/expand.c ++++ b/src/expand.c +@@ -1871,11 +1871,11 @@ + { + tree_node * node = tree_search(router_var, name + 2); + return node ? node->data.ptr : strict_acl_vars ? NULL : US""; + } + +-/* Handle $auth<n> variables. */ ++/* Handle $auth<n>, $regex<n> variables. */ + + if (Ustrncmp(name, "auth", 4) == 0) + { + uschar *endptr; + int n = Ustrtoul(name + 4, &endptr, 10); +--- a/src/functions.h ++++ b/src/functions.h +@@ -436,10 +436,11 @@ + extern int regex(const uschar **); + #endif + extern BOOL regex_match(const pcre2_code *, const uschar *, int, uschar **); + extern BOOL regex_match_and_setup(const pcre2_code *, const uschar *, int, int); + extern const pcre2_code *regex_must_compile(const uschar *, BOOL, BOOL); ++extern void regex_vars_clear(void); + extern void retry_add_item(address_item *, uschar *, int); + extern BOOL retry_check_address(const uschar *, host_item *, uschar *, BOOL, + uschar **, uschar **); + extern retry_config *retry_find_config(const uschar *, const uschar *, int, int); + extern BOOL retry_ultimate_address_timeout(uschar *, const uschar *, +--- a/src/globals.c ++++ b/src/globals.c +@@ -1313,11 +1313,11 @@ + #ifndef DISABLE_PIPE_CONNECT + const pcre2_code *regex_EARLY_PIPE = NULL; + #endif + const pcre2_code *regex_ismsgid = NULL; + const pcre2_code *regex_smtp_code = NULL; +-const uschar *regex_vars[REGEX_VARS]; ++const uschar *regex_vars[REGEX_VARS] = { 0 };; + #ifdef WHITELIST_D_MACROS + const pcre2_code *regex_whitelisted_macro = NULL; + #endif + #ifdef WITH_CONTENT_SCAN + uschar *regex_match_string = NULL; +--- a/src/regex.c ++++ b/src/regex.c +@@ -94,22 +94,32 @@ + } + pcre2_match_data_free(md); + return FAIL; + } + ++ ++/* reset expansion variables */ ++void ++regex_vars_clear(void) ++{ ++regex_match_string = NULL; ++for (int i = 0; i < REGEX_VARS; i++) regex_vars[i] = NULL; ++} ++ ++ ++ + int +-regex(const uschar **listptr) ++regex(const uschar ** listptr) + { + unsigned long mbox_size; +-FILE *mbox_file; +-pcre_list *re_list_head; +-uschar *linebuffer; ++FILE * mbox_file; ++pcre_list * re_list_head; ++uschar * linebuffer; + long f_pos = 0; + int ret = FAIL; + +-/* reset expansion variable */ +-regex_match_string = NULL; ++regex_vars_clear(); + + if (!mime_stream) /* We are in the DATA ACL */ + { + if (!(mbox_file = spool_mbox(&mbox_size, NULL, NULL))) + { /* error while spooling */ +@@ -167,18 +177,17 @@ + + + int + mime_regex(const uschar **listptr) + { +-pcre_list *re_list_head = NULL; +-FILE *f; +-uschar *mime_subject = NULL; ++pcre_list * re_list_head = NULL; ++FILE * f; ++uschar * mime_subject = NULL; + int mime_subject_len = 0; + int ret; + +-/* reset expansion variable */ +-regex_match_string = NULL; ++regex_vars_clear(); + + /* precompile our regexes */ + if (!(re_list_head = compile(*listptr))) + return FAIL; /* no regexes -> nothing to do */ + +--- a/src/smtp_in.c ++++ b/src/smtp_in.c +@@ -2155,12 +2155,14 @@ + prdr_requested = FALSE; + #endif + #ifdef SUPPORT_I18N + message_smtputf8 = FALSE; + #endif ++regex_vars_clear(); + body_linecount = body_zerocount = 0; + ++lookup_value = NULL; /* Can be set by ACL */ + sender_rate = sender_rate_limit = sender_rate_period = NULL; + ratelimiters_mail = NULL; /* Updated by ratelimit ACL condition */ + /* Note that ratelimiters_conn persists across resets. */ + + /* Reset message ACL variables */
package/exim/0007-Fix-non-WITH_CONTENT_SCAN-build.patch new file +61 -0
61 lines not on this page · raw message
package/exim/0008-Fix-non-WITH_CONTENT_SCAN-build-2.patch new file +139 -0
139 lines not on this page · raw message
package/exim/0009-Fix-non-WITH_CONTENT_SCAN-build-3.patch new file +49 -0
49 lines not on this page · raw message
package/exim/exim.mk +3 -0
@@ -13,6 +13,9 @@ EXIM_CPE_ID_VENDOR = exim EXIM_SELINUX_MODULES = exim mta EXIM_DEPENDENCIES = host-berkeleydb host-pcre2 pcre2 berkeleydb host-pkgconf +# 0006-Fix-regex-n-use-after-free.-Bug-2915.patch +EXIM_IGNORE_CVES += CVE-2022-3559 + # Modify a variable value. It must already exist in the file, either # commented or not. define exim-config-change # variable-name, variable-value
Signature · 6 lines
2.30.2 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 2/2 package/exim: mark CVE-2022-3620 as ignored
CVE-2022-3620: A vulnerability was found in Exim and classified as problematic. This issue affects the function dmarc_dns_lookup of the file dmarc.c of the component DMARC Handler. The manipulation leads to use after free. The attack may be initiated remotely. The name of the patch is 12fb3842f81bcbd4a4519d5728f2d7e0e3ca1445. It is recommended to apply a patch to fix this issue. The associated identifier of this vulnerability is VDB-211919.
This vulnerability is in the DMARC handling, which is only used if libopendmarc is available AND SUPPORT_DMARC is set to yes, neither of which is true for Buildroot, so ignore the CVE.
--- package/exim/exim.mk | 3 +++ 1 file changed, 3 insertions(+)
package/exim/exim.mk +3 -0
@@ -16,6 +16,9 @@ EXIM_DEPENDENCIES = host-berkeleydb host-pcre2 pcre2 berkeleydb host-pkgconf # 0006-Fix-regex-n-use-after-free.-Bug-2915.patch EXIM_IGNORE_CVES += CVE-2022-3559 +# built without dmarc support +EXIM_IGNORE_CVES += CVE-2022-3620 + # Modify a variable value. It must already exist in the file, either # commented or not. define exim-config-change # variable-name, variable-value
Signature · 6 lines
2.30.2 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Thomas Petazzoni via buildroot
AppliedRe: [Buildroot] [PATCH 2/2] package/exim: mark CVE-2022-3620 as ignored
Quoted 8 lines · On Fri, 2 Dec 2022 19:36:31 +0100 Peter Korsgaard <[email protected]> wrote:
CVE-2022-3620: A vulnerability was found in Exim and classified as problematic. This issue affects the function
dmarc_dns_lookupof the filedmarc.cof the component DMARC Handler. The manipulation leads to use after free. The attack may be initiated remotely. The name of the patch is12fb3842f81bcbd4a4519d5728f2d7e0e3ca1445. It is recommended to apply a patch to fix this issue. The associated identifier of this vulnerability is VDB-211919.
Quoted 8 lines
This vulnerability is in the DMARC handling, which is only used if libopendmarc is available AND
SUPPORT_DMARCis set to yes, neither of which is true for Buildroot, so ignore the CVE.Signed-off-by Peter Korsgaard <[email protected]>--- package/exim/exim.mk | 3 +++ 1 file changed, 3 insertions(+)
We need to be careful to un-ignore this CVE if we enable DMARC support before we bump to a newer release that has the CVE fixed. But admittedly, it's unlikely that we will enable DMARC support anytime soon.
Applied to master, thanks!
Thomas
Signature · 7 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 2/2] package/exim: mark CVE-2022-3620 as ignored
In reply to Peter KorsgaardQuoted 10 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Peter" == Peter Korsgaard <[email protected]> writes:
CVE-2022-3620: A vulnerability was found in Exim and classified as problematic. This issue affects the function
dmarc_dns_lookupof the filedmarc.cof the component DMARC Handler. The manipulation leads to use after free. The attack may be initiated remotely. The name of the patch is12fb3842f81bcbd4a4519d5728f2d7e0e3ca1445. It is recommended to apply a patch to fix this issue. The associated identifier of this vulnerability is VDB-211919.
Quoted 5 lines
This vulnerability is in the DMARC handling, which is only used if libopendmarc is available AND
SUPPORT_DMARCis set to yes, neither of which is true for Buildroot, so ignore the CVE.Signed-off-by Peter Korsgaard <[email protected]>
Committed to 2022.08.x and 2022.02.x, thanks.
Signature · 5 lines
Bye, Peter Korsgaard _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 11 lines · On Fri, 2 Dec 2022 19:36:30 +0100 Peter Korsgaard <[email protected]> wrote:
Fixes CVE-2022-3559: A vulnerability was found in Exim and classified as problematic. This issue affects some unknown processing of the component Regex Handler. The manipulation leads to use after free. The name of the patch is
4e9ed49f8f12eb331b29bd5b6dc3693c520fddc2. It is recommended to apply a patch to fix this issue. The identifier VDB-211073 was assigned to this vulnerability.The upstream patch does not apply to 4.96, so use the backported patches from Debian. Amazingly, the patch needs 3 additional patches to unbreak builds without "
WITH_CONTENT_SCAN" (default in Buildroot), so add those as well.
What a mess :-/
Review
Quoted 3 lines
(quoted diff) +3
-0+Subject: [PATCH 1/3] Fix non-WITH_CONTENT_SCAN build. +Subject: [PATCH 2/3] Fix non-WITH_CONTENT_SCAN build (2) +Subject: [PATCH 3/3] Fix non-WITH_CONTENT_SCAN build (3)
You forgot to drop the patch numbering, so I did it when applying to master. Thanks!
Thomas
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 9 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Peter" == Peter Korsgaard <[email protected]> writes:
Fixes CVE-2022-3559: A vulnerability was found in Exim and classified as problematic. This issue affects some unknown processing of the component Regex Handler. The manipulation leads to use after free. The name of the patch is
4e9ed49f8f12eb331b29bd5b6dc3693c520fddc2. It is recommended to apply a patch to fix this issue. The identifier VDB-211073 was assigned to this vulnerability.
Quoted 6 lines
The upstream patch does not apply to 4.96, so use the backported patches from Debian. Amazingly, the patch needs 3 additional patches to unbreak builds without "
WITH_CONTENT_SCAN" (default in Buildroot), so add those as well.Signed-off-by Peter Korsgaard <[email protected]>
Committed to 2022.08.x and 2022.02.x, thanks.
Signature · 5 lines
Bye, Peter Korsgaard _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot