From 37ded08e07040ca3f06f9ab028d9e8139c51515f Mon Sep 17 00:00:00 2001 From: xuchenchen Date: Sun, 16 Jun 2024 21:04:18 +0800 Subject: [PATCH] backport CVE-2024-38428 (cherry picked from commit b1906cb10078f93ba92a2ecaab7ece0862463b5c) --- backport-CVE-2024-38428.patch | 76 +++++++++++++++++++++++++++++++++++ wget.spec | 9 ++++- 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 backport-CVE-2024-38428.patch diff --git a/backport-CVE-2024-38428.patch b/backport-CVE-2024-38428.patch new file mode 100644 index 0000000..a9ae1ec --- /dev/null +++ b/backport-CVE-2024-38428.patch @@ -0,0 +1,76 @@ +From ed0c7c7e0e8f7298352646b2fd6e06a11e242ace Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Tim=20R=C3=BChsen?= +Date: Sun, 2 Jun 2024 12:40:16 +0200 +Subject: Properly re-implement userinfo parsing (rfc2396) + +* src/url.c (url_skip_credentials): Properly re-implement userinfo parsing (rfc2396) + +The reason why the implementation is based on RFC 2396, an outdated standard, +is that the whole file is based on that RFC, and mixing standard here might be +dangerous. + +--- + src/url.c | 40 ++++++++++++++++++++++++++++++++++------ + 1 file changed, 34 insertions(+), 6 deletions(-) + +diff --git a/src/url.c b/src/url.c +index ddc72d0..65dd27d 100644 +--- a/src/url.c ++++ b/src/url.c +@@ -41,6 +41,7 @@ as that of the covered work. */ + #include "url.h" + #include "host.h" /* for is_valid_ipv6_address */ + #include "c-strcase.h" ++#include "c-ctype.h" + + #ifdef HAVE_ICONV + # include +@@ -526,12 +527,39 @@ scheme_leading_string (enum url_scheme scheme) + static const char * + url_skip_credentials (const char *url) + { +- /* Look for '@' that comes before terminators, such as '/', '?', +- '#', or ';'. */ +- const char *p = (const char *)strpbrk (url, "@/?#;"); +- if (!p || *p != '@') +- return url; +- return p + 1; ++ /* ++ * This whole file implements https://www.rfc-editor.org/rfc/rfc2396 . ++ * RFC 2396 is outdated since 2005 and needs a rewrite or a thorough re-visit. ++ * ++ * The RFC says ++ * server = [ [ userinfo "@" ] hostport ] ++ * userinfo = *( unreserved | escaped | ";" | ":" | "&" | "=" | "+" | "$" | "," ) ++ * unreserved = alphanum | mark ++ * mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")" ++ */ ++ static const char *allowed = "-_.!~*'();:&=+$,"; ++ ++ for (const char *p = url; *p; p++) ++ { ++ if (c_isalnum(*p)) ++ continue; ++ ++ if (strchr(allowed, *p)) ++ continue; ++ ++ if (*p == '%' && c_isxdigit(p[1]) && c_isxdigit(p[2])) ++ { ++ p += 2; ++ continue; ++ } ++ ++ if (*p == '@') ++ return p + 1; ++ ++ break; ++ } ++ ++ return url; + } + + /* Parse credentials contained in [BEG, END). The region is expected +-- +2.33.0 + diff --git a/wget.spec b/wget.spec index 6b1e10f..5da30e8 100644 --- a/wget.spec +++ b/wget.spec @@ -1,6 +1,6 @@ Name: wget Version: 1.21.2 -Release: 3 +Release: 4 Summary: A package for retrieving files using HTTP, HTTPS, FTP and FTPS the most widely-used Internet protocols. License: GPLv3+ Url: http://www.gnu.org/software/wget/ @@ -9,6 +9,7 @@ Source: https://ftp.gnu.org/gnu/wget/wget-%{version}.tar.gz Patch0: backport-wget-1.21-ssl-init-output.patch Patch1: backport-wget-1.21-segfault.patch Patch2: backport-src-main.c-main-Remove-unused-variable.patch +Patch3: backport-CVE-2024-38428.patch Provides: webclient bundled(gnulib) BuildRequires: perl-HTTP-Daemon python3 libuuid-devel perl-podlators libpsl-devel libmetalink-devel @@ -56,6 +57,12 @@ make check %{_infodir}/* %changelog +* Sun Jun 16 2024 xuchenchen -1.21.2-4 +- Type:CVES +- ID:NA +- SUG:NA +- DESC:backport CVE-2024-38428 + * Sat Jun 17 2023 xingwei - 1.21.2-3 - Type:bugfix - ID:NA -- Gitee