diff options
| author | Peter Marko <peter.marko@siemens.com> | 2024-11-09 12:42:27 +0100 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2024-11-15 06:05:32 -0800 |
| commit | e82352ffb4fe0a6db36d9de7a4209935dc4e0a87 (patch) | |
| tree | 651b77d32aaeeb0e1643607f2cae48641bc8b614 | |
| parent | a84e68cd5d6a690c3afe76cab789f3e0878db7a2 (diff) | |
| download | poky-e82352ffb4fe0a6db36d9de7a4209935dc4e0a87.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: fbb8928ea85980bb866febd66e5e18ad843dbef8)
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.patch | 85 | ||||
| -rw-r--r-- | meta/recipes-support/curl/curl_7.82.0.bb | 1 |
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..e6c8bf7223 --- /dev/null +++ b/meta/recipes-support/curl/curl/CVE-2024-9681.patch | |||
| @@ -0,0 +1,85 @@ | |||
| 1 | From a94973805df96269bf3f3bf0a20ccb9887313316 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Daniel Stenberg <daniel@haxx.se> | ||
| 3 | Date: Wed, 9 Oct 2024 10:04:35 +0200 | ||
| 4 | Subject: [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 | |||
| 12 | Closes #15210 | ||
| 13 | |||
| 14 | CVE: CVE-2024-9681 | ||
| 15 | Upstream-Status: Backport [https://github.com/curl/curl/commit/a94973805df96269bf3f3bf0a20ccb9887313316] | ||
| 16 | Signed-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 | |||
| 22 | diff --git a/lib/hsts.c b/lib/hsts.c | ||
| 23 | index d5e883f51ef0f7..12052ce53c1c5a 100644 | ||
| 24 | --- a/lib/hsts.c | ||
| 25 | +++ b/lib/hsts.c | ||
| 26 | @@ -247,12 +247,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 | @@ -277,15 +279,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 | - Curl_strncasecompare(&hostname[offs], sts->host, ntail)) | ||
| 46 | - return sts; | ||
| 47 | + Curl_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(Curl_strcasecompare(hostname, sts->host)) | ||
| 56 | return sts; | ||
| 57 | } | ||
| 58 | } | ||
| 59 | - return NULL; /* no match */ | ||
| 60 | + return bestsub; | ||
| 61 | } | ||
| 62 | |||
| 63 | /* | ||
| 64 | @@ -447,7 +453,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(Curl_strcasecompare(p, e->host)) { | ||
| 70 | /* the same host name, use the largest expire time */ | ||
| 71 | if(expires > e->expires) | ||
| 72 | e->expires = expires; | ||
| 73 | diff --git a/tests/data/test1660 b/tests/data/test1660 | ||
| 74 | index 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_7.82.0.bb b/meta/recipes-support/curl/curl_7.82.0.bb index ba3abadac9..cda42da4d3 100644 --- a/meta/recipes-support/curl/curl_7.82.0.bb +++ b/meta/recipes-support/curl/curl_7.82.0.bb | |||
| @@ -62,6 +62,7 @@ SRC_URI = "https://curl.se/download/${BP}.tar.xz \ | |||
| 62 | file://CVE-2024-7264_2.patch \ | 62 | file://CVE-2024-7264_2.patch \ |
| 63 | file://CVE-2024-8096.patch \ | 63 | file://CVE-2024-8096.patch \ |
| 64 | file://0001-url-free-old-conn-better-on-reuse.patch \ | 64 | file://0001-url-free-old-conn-better-on-reuse.patch \ |
| 65 | file://CVE-2024-9681.patch \ | ||
| 65 | " | 66 | " |
| 66 | SRC_URI[sha256sum] = "0aaa12d7bd04b0966254f2703ce80dd5c38dbbd76af0297d3d690cdce58a583c" | 67 | SRC_URI[sha256sum] = "0aaa12d7bd04b0966254f2703ce80dd5c38dbbd76af0297d3d690cdce58a583c" |
| 67 | 68 | ||
