From bcd660b4a7608246d87089a8042609ff101f33c1 Mon Sep 17 00:00:00 2001 From: xuchenchen Date: Sun, 9 Jun 2024 11:29:25 +0800 Subject: [PATCH] backport CVE-2024-3049 (cherry picked from commit e8bba8a56f8038e061248a2a01e0f81ef0ee32c1) --- backport-CVE-2024-3049.patch | 80 ++++++++++++++++++++++++++++++++++++ booth.spec | 9 +++- 2 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 backport-CVE-2024-3049.patch diff --git a/backport-CVE-2024-3049.patch b/backport-CVE-2024-3049.patch new file mode 100644 index 0000000..e5b15a9 --- /dev/null +++ b/backport-CVE-2024-3049.patch @@ -0,0 +1,80 @@ +From 98b4284d1701f2efec278b51f151314148bfe70e Mon Sep 17 00:00:00 2001 +From: Jan Friesse +Date: Wed, 21 Feb 2024 18:12:28 +0100 +Subject: [PATCH] auth: Check result of gcrypt gcry_md_get_algo_dlen + +When unknown hash is passed to gcry_md_get_algo_dlen 0 is returned. This +value is then used for memcmp so wrong hmac might be accepted as +correct. + +Signed-off-by: Jan Friesse + +--- + src/attr.c | 2 +- + src/auth.c | 16 +++++++++++++--- + 2 files changed, 14 insertions(+), 4 deletions(-) + +diff --git a/src/attr.c b/src/attr.c +index 09c15bc..e615c33 100644 +--- a/src/attr.c ++++ b/src/attr.c +@@ -142,7 +142,7 @@ static int read_server_reply( + return -2; + } + len = ntohl(header->length); +- rv = tpt->recv(site, msg+len, len-sizeof(*header)); ++ rv = tpt->recv(site, msg+sizeof(*header), len-sizeof(*header)); + if (rv < 0) { + return -1; + } +diff --git a/src/auth.c b/src/auth.c +index 8f86b9a..a3b3d20 100644 +--- a/src/auth.c ++++ b/src/auth.c +@@ -28,6 +28,11 @@ int calc_hmac(const void *data, size_t datalen, + { + static gcry_md_hd_t digest; + gcry_error_t err; ++ int hlen; ++ ++ hlen = gcry_md_get_algo_dlen(hid); ++ if (!hlen) ++ return -1; + + if (!digest) { + err = gcry_md_open(&digest, hid, GCRY_MD_FLAG_HMAC); +@@ -42,7 +47,7 @@ int calc_hmac(const void *data, size_t datalen, + } + } + gcry_md_write(digest, data, datalen); +- memcpy(result, gcry_md_read(digest, 0), gcry_md_get_algo_dlen(hid)); ++ memcpy(result, gcry_md_read(digest, 0), hlen); + gcry_md_reset(digest); + return 0; + } +@@ -54,15 +59,20 @@ int verify_hmac(const void *data, size_t datalen, + { + unsigned char *our_hmac; + int rc; ++ int hlen; ++ ++ hlen = gcry_md_get_algo_dlen(hid); ++ if (!hlen) ++ return -1; + +- our_hmac = malloc(gcry_md_get_algo_dlen(hid)); ++ our_hmac = malloc(hlen); + if (!our_hmac) + return -1; + + rc = calc_hmac(data, datalen, hid, our_hmac, key, keylen); + if (rc) + goto out_free; +- rc = memcmp(our_hmac, hmac, gcry_md_get_algo_dlen(hid)); ++ rc = memcmp(our_hmac, hmac, hlen); + + out_free: + if (our_hmac) +-- +2.23.0 + diff --git a/booth.spec b/booth.spec index 53ee0ef..6a10d61 100644 --- a/booth.spec +++ b/booth.spec @@ -10,7 +10,7 @@ %global git_describe_str v1.0-283-g9d4029aa14323a7f3b496215d25e40bd14f33632 # Set this to 1 when rebasing (changing git_describe_str) and increase otherwise -%global release 6 +%global release 7 # Run shell script to parse git_describe str into version, numcomm and sha1 hash %global booth_ver %(s=%{git_describe_str}; vver=${s%%%%-*}; echo ${vver:1}) @@ -37,6 +37,7 @@ Summary: Ticket Manager for Multi-site Clusters License: GPLv2+ Url: https://github.com/%{github_owner}/%{name} Source0: https://github.com/%{github_owner}/%{name}/archive/%{booth_short_sha1}/%{booth_archive_name}.tar.gz +Patch3000: backport-CVE-2024-3049.patch # direct build process dependencies BuildRequires: autoconf @@ -262,6 +263,12 @@ VERBOSE=1 make check %{_usr}/lib/ocf/resource.d/booth/sharedrsc %changelog +* Sun Jun 09 2024 xuchenchen -1.0-7 +- Type:CVES +- ID:CVE-2024-3049 +- SUG:NA +- DESC:fix CVE-2024-3049 + * Fri May 19 2023 jiangxinyu - 1.0-6 - Rebase to newest upstream snapshot -- Gitee