Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Medium] patch rust to fix CVE-2024-9681 #12165

Open
wants to merge 2 commits into
base: fasttrack/3.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions SPECS/rust/CVE-2024-9681.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
From 1a4305628fd46e50614cc4e918a834db8fe1d1e3 Mon Sep 17 00:00:00 2001
From: jykanase <[email protected]>
Date: Mon, 27 Jan 2025 06:55:46 +0000
Subject: [PATCH] CVE-2024-9681

Backported form: https://github.com/curl/curl/commit/a94973805df96269bf
---
vendor/curl-sys-0.4.63+curl-8.1.2/curl/lib/hsts.c | 14 ++++++++++----
vendor/curl-sys/curl/lib/hsts.c | 14 ++++++++++----
2 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/vendor/curl-sys-0.4.63+curl-8.1.2/curl/lib/hsts.c b/vendor/curl-sys-0.4.63+curl-8.1.2/curl/lib/hsts.c
index 53c01fc52..edbcfab99 100644
--- a/vendor/curl-sys-0.4.63+curl-8.1.2/curl/lib/hsts.c
+++ b/vendor/curl-sys-0.4.63+curl-8.1.2/curl/lib/hsts.c
@@ -248,12 +248,14 @@ CURLcode Curl_hsts_parse(struct hsts *h, const char *hostname,
struct stsentry *Curl_hsts(struct hsts *h, const char *hostname,
bool subdomain)
{
+ struct stsentry *bestsub = NULL;
if(h) {
char buffer[MAX_HSTS_HOSTLEN + 1];
time_t now = time(NULL);
size_t hlen = strlen(hostname);
struct Curl_llist_element *e;
struct Curl_llist_element *n;
+ size_t blen = 0;

if((hlen > MAX_HSTS_HOSTLEN) || !hlen)
return NULL;
@@ -278,15 +280,19 @@ struct stsentry *Curl_hsts(struct hsts *h, const char *hostname,
if(ntail < hlen) {
size_t offs = hlen - ntail;
if((hostname[offs-1] == '.') &&
- strncasecompare(&hostname[offs], sts->host, ntail))
- return sts;
+ strncasecompare(&hostname[offs], sts->host, ntail) &&
+ (ntail > blen)) {
+ /* save the tail match with the longest tail */
+ bestsub = sts;
+ blen = ntail;
+ }
}
}
if(strcasecompare(hostname, sts->host))
return sts;
}
}
- return NULL; /* no match */
+ return bestsub;
}

/*
@@ -438,7 +444,7 @@ static CURLcode hsts_add(struct hsts *h, char *line)
e = Curl_hsts(h, p, subdomain);
if(!e)
result = hsts_create(h, p, subdomain, expires);
- else {
+ else if(strcasecompare(p, e->host)) {
/* the same host name, use the largest expire time */
if(expires > e->expires)
e->expires = expires;
diff --git a/vendor/curl-sys/curl/lib/hsts.c b/vendor/curl-sys/curl/lib/hsts.c
index 7ecf0042a..3d11f258e 100644
--- a/vendor/curl-sys/curl/lib/hsts.c
+++ b/vendor/curl-sys/curl/lib/hsts.c
@@ -249,12 +249,14 @@ CURLcode Curl_hsts_parse(struct hsts *h, const char *hostname,
struct stsentry *Curl_hsts(struct hsts *h, const char *hostname,
bool subdomain)
{
+ struct stsentry *bestsub = NULL;
if(h) {
char buffer[MAX_HSTS_HOSTLEN + 1];
time_t now = time(NULL);
size_t hlen = strlen(hostname);
struct Curl_llist_element *e;
struct Curl_llist_element *n;
+ size_t blen = 0;

if((hlen > MAX_HSTS_HOSTLEN) || !hlen)
return NULL;
@@ -279,15 +281,19 @@ struct stsentry *Curl_hsts(struct hsts *h, const char *hostname,
if(ntail < hlen) {
size_t offs = hlen - ntail;
if((hostname[offs-1] == '.') &&
- strncasecompare(&hostname[offs], sts->host, ntail))
- return sts;
+ strncasecompare(&hostname[offs], sts->host, ntail) &&
+ (ntail > blen)) {
+ /* save the tail match with the longest tail */
+ bestsub = sts;
+ blen = ntail;
+ }
}
}
if(strcasecompare(hostname, sts->host))
return sts;
}
}
- return NULL; /* no match */
+ return bestsub;
}

/*
@@ -439,7 +445,7 @@ static CURLcode hsts_add(struct hsts *h, char *line)
e = Curl_hsts(h, p, subdomain);
if(!e)
result = hsts_create(h, p, subdomain, expires);
- else {
+ else if(strcasecompare(p, e->host)) {
/* the same host name, use the largest expire time */
if(expires > e->expires)
e->expires = expires;
--
2.45.2

6 changes: 5 additions & 1 deletion SPECS/rust/rust.spec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Summary: Rust Programming Language
Name: rust
Version: 1.75.0
Release: 11%{?dist}
Release: 12%{?dist}
License: (ASL 2.0 OR MIT) AND BSD AND CC-BY-3.0
Vendor: Microsoft Corporation
Distribution: Azure Linux
Expand Down Expand Up @@ -44,6 +44,7 @@ Source7: https://static.rust-lang.org/dist/%{release_date}/rust-std-%{sta
Patch0: CVE-2023-45853.patch
Patch1: CVE-2024-32884.patch
Patch2: CVE-2024-31852.patch
Patch3: CVE-2024-9681.patch

BuildRequires: binutils
BuildRequires: cmake
Expand Down Expand Up @@ -172,6 +173,9 @@ rm %{buildroot}%{_bindir}/*.old
%{_mandir}/man1/*

%changelog
* Fri Jan 31 2025 Jyoti Kanase <[email protected]> - 1.75.0-12
- Fix CVE-2024-9681

* Mon Aug 26 2024 Rachel Menge <[email protected]> - 1.75.0-11
- Update to build dep latest glibc-static version

Expand Down
Loading