summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Marko <peter.marko@siemens.com>2024-11-09 12:41:15 +0100
committerSteve Sakoman <steve@sakoman.com>2024-11-18 06:59:35 -0800
commit855c30fc81b2bce777873759f120c401c489d043 (patch)
tree36836f1a143065af03b81f54d7afbc49dd2be1d0
parent19b2afe4af9064461153820483db6c4b30d6996f (diff)
downloadpoky-855c30fc81b2bce777873759f120c401c489d043.tar.gz
curl: patch CVE-2024-9681
Picked commit [1] per solution described in [2]. [1] https://github.com/curl/curl/commit/a94973805df96269bf [2] https://curl.se/docs/CVE-2024-9681.html (From OE-Core rev: 19663c559b72a0d14ddd0792be325284a6e16edc) Signed-off-by: Peter Marko <peter.marko@siemens.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r--meta/recipes-support/curl/curl/CVE-2024-9681.patch85
-rw-r--r--meta/recipes-support/curl/curl_8.7.1.bb1
2 files changed, 86 insertions, 0 deletions
diff --git a/meta/recipes-support/curl/curl/CVE-2024-9681.patch b/meta/recipes-support/curl/curl/CVE-2024-9681.patch
new file mode 100644
index 0000000000..d9131228fc
--- /dev/null
+++ b/meta/recipes-support/curl/curl/CVE-2024-9681.patch
@@ -0,0 +1,85 @@
1From a94973805df96269bf3f3bf0a20ccb9887313316 Mon Sep 17 00:00:00 2001
2From: Daniel Stenberg <daniel@haxx.se>
3Date: Wed, 9 Oct 2024 10:04:35 +0200
4Subject: [PATCH] hsts: improve subdomain handling
5
6- on load, only replace existing HSTS entries if there is a full host
7 match
8
9- on matching, prefer a full host match and secondary the longest tail
10 subdomain match
11
12Closes #15210
13
14CVE: CVE-2024-9681
15Upstream-Status: Backport [https://github.com/curl/curl/commit/a94973805df96269bf3f3bf0a20ccb9887313316]
16Signed-off-by: Peter Marko <peter.marko@siemens.com>
17---
18 lib/hsts.c | 14 ++++++++++----
19 tests/data/test1660 | 2 +-
20 2 files changed, 11 insertions(+), 5 deletions(-)
21
22diff --git a/lib/hsts.c b/lib/hsts.c
23index d5e883f51ef0f7..12052ce53c1c5a 100644
24--- a/lib/hsts.c
25+++ b/lib/hsts.c
26@@ -254,12 +254,14 @@ CURLcode Curl_hsts_parse(struct hsts *h, const char *hostname,
27 struct stsentry *Curl_hsts(struct hsts *h, const char *hostname,
28 bool subdomain)
29 {
30+ struct stsentry *bestsub = NULL;
31 if(h) {
32 char buffer[MAX_HSTS_HOSTLEN + 1];
33 time_t now = time(NULL);
34 size_t hlen = strlen(hostname);
35 struct Curl_llist_element *e;
36 struct Curl_llist_element *n;
37+ size_t blen = 0;
38
39 if((hlen > MAX_HSTS_HOSTLEN) || !hlen)
40 return NULL;
41@@ -284,15 +286,19 @@ struct stsentry *Curl_hsts(struct hsts *h, const char *hostname,
42 if(ntail < hlen) {
43 size_t offs = hlen - ntail;
44 if((hostname[offs-1] == '.') &&
45- strncasecompare(&hostname[offs], sts->host, ntail))
46- return sts;
47+ strncasecompare(&hostname[offs], sts->host, ntail) &&
48+ (ntail > blen)) {
49+ /* save the tail match with the longest tail */
50+ bestsub = sts;
51+ blen = ntail;
52+ }
53 }
54 }
55 if(strcasecompare(hostname, sts->host))
56 return sts;
57 }
58 }
59- return NULL; /* no match */
60+ return bestsub;
61 }
62
63 /*
64@@ -444,7 +450,7 @@ static CURLcode hsts_add(struct hsts *h, char *line)
65 e = Curl_hsts(h, p, subdomain);
66 if(!e)
67 result = hsts_create(h, p, subdomain, expires);
68- else {
69+ else if(strcasecompare(p, e->host)) {
70 /* the same host name, use the largest expire time */
71 if(expires > e->expires)
72 e->expires = expires;
73diff --git a/tests/data/test1660 b/tests/data/test1660
74index f86126d19cf269..4b6f9615c9d517 100644
75--- a/tests/data/test1660
76+++ b/tests/data/test1660
77@@ -52,7 +52,7 @@ this.example [this.example]: 1548400797
78 Input 12: error 43
79 Input 13: error 43
80 Input 14: error 43
81-3.example.com [example.com]: 1569905261 includeSubDomains
82+3.example.com [3.example.com]: 1569905261 includeSubDomains
83 3.example.com [example.com]: 1569905261 includeSubDomains
84 foo.example.com [example.com]: 1569905261 includeSubDomains
85 'foo.xample.com' is not HSTS
diff --git a/meta/recipes-support/curl/curl_8.7.1.bb b/meta/recipes-support/curl/curl_8.7.1.bb
index d094604ea1..439fcb7881 100644
--- a/meta/recipes-support/curl/curl_8.7.1.bb
+++ b/meta/recipes-support/curl/curl_8.7.1.bb
@@ -19,6 +19,7 @@ SRC_URI = " \
19 file://CVE-2024-7264-1.patch \ 19 file://CVE-2024-7264-1.patch \
20 file://CVE-2024-7264-2.patch \ 20 file://CVE-2024-7264-2.patch \
21 file://CVE-2024-8096.patch \ 21 file://CVE-2024-8096.patch \
22 file://CVE-2024-9681.patch \
22" 23"
23SRC_URI[sha256sum] = "6fea2aac6a4610fbd0400afb0bcddbe7258a64c63f1f68e5855ebc0c659710cd" 24SRC_URI[sha256sum] = "6fea2aac6a4610fbd0400afb0bcddbe7258a64c63f1f68e5855ebc0c659710cd"
24 25