diff --git a/backport-CVE-2023-38709-header-validation-after-content.patch b/backport-CVE-2023-38709-header-validation-after-content.patch new file mode 100644 index 0000000000000000000000000000000000000000..a5987fd01e4e94058e68c2e635bb735bd3089dd3 --- /dev/null +++ b/backport-CVE-2023-38709-header-validation-after-content.patch @@ -0,0 +1,97 @@ +From ac20389f3c816d990aba21720f1492b69ac5cb44 Mon Sep 17 00:00:00 2001 +From: Eric Covener +Date: Wed, 3 Apr 2024 12:12:23 +0000 +Subject: [PATCH] header validation after content-* are eval'ed + +backport r1916770 from trunk +Submitted By: ylavic + + + + +git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1916778 13f79535-47bb-0310-9956-ffa450edef68 + +Conflict:NA +Reference:https://github.com/apache/httpd/commit/ac20389f3c816d990aba21720f1492b69ac5cb44 + +--- + modules/http/http_filters.c | 28 ++++++++++++++++------------ + 1 file changed, 16 insertions(+), 12 deletions(-) + +diff --git a/modules/http/http_filters.c b/modules/http/http_filters.c +index e9faa2e..4073fc9 100644 +--- a/modules/http/http_filters.c ++++ b/modules/http/http_filters.c +@@ -1360,6 +1360,9 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, + */ + apr_table_clear(r->headers_out); + apr_table_clear(r->err_headers_out); ++ r->content_type = r->content_encoding = NULL; ++ r->content_languages = NULL; ++ r->clength = r->chunked = 0; + apr_brigade_cleanup(b); + + /* Don't recall ap_die() if we come back here (from its own internal +@@ -1376,8 +1379,6 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, + APR_BRIGADE_INSERT_TAIL(b, e); + e = apr_bucket_eos_create(c->bucket_alloc); + APR_BRIGADE_INSERT_TAIL(b, e); +- r->content_type = r->content_encoding = NULL; +- r->content_languages = NULL; + ap_set_content_length(r, 0); + recursive_error = 1; + } +@@ -1404,6 +1405,7 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, + if (!apr_is_empty_table(r->err_headers_out)) { + r->headers_out = apr_table_overlay(r->pool, r->err_headers_out, + r->headers_out); ++ apr_table_clear(r->err_headers_out); + } + + /* +@@ -1423,6 +1425,17 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, + fixup_vary(r); + } + ++ ++ /* ++ * Control cachability for non-cacheable responses if not already set by ++ * some other part of the server configuration. ++ */ ++ if (r->no_cache && !apr_table_get(r->headers_out, "Expires")) { ++ char *date = apr_palloc(r->pool, APR_RFC822_DATE_LEN); ++ ap_recent_rfc822_date(date, r->request_time); ++ apr_table_addn(r->headers_out, "Expires", date); ++ } ++ + /* + * Now remove any ETag response header field if earlier processing + * says so (such as a 'FileETag None' directive). +@@ -1435,6 +1448,7 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, + basic_http_header_check(r, &protocol); + ap_set_keepalive(r); + ++ /* 204/304 responses don't have content related headers */ + if (AP_STATUS_IS_HEADER_ONLY(r->status)) { + apr_table_unset(r->headers_out, "Transfer-Encoding"); + apr_table_unset(r->headers_out, "Content-Length"); +@@ -1477,16 +1491,6 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, + apr_table_setn(r->headers_out, "Content-Language", field); + } + +- /* +- * Control cachability for non-cacheable responses if not already set by +- * some other part of the server configuration. +- */ +- if (r->no_cache && !apr_table_get(r->headers_out, "Expires")) { +- char *date = apr_palloc(r->pool, APR_RFC822_DATE_LEN); +- ap_recent_rfc822_date(date, r->request_time); +- apr_table_addn(r->headers_out, "Expires", date); +- } +- + /* This is a hack, but I can't find anyway around it. The idea is that + * we don't want to send out 0 Content-Lengths if it is a head request. + * This happens when modules try to outsmart the server, and return +-- +2.33.0 + diff --git a/backport-CVE-2024-24795-let-httpd-handle-CL-TE-for-non-http-handlers.patch b/backport-CVE-2024-24795-let-httpd-handle-CL-TE-for-non-http-handlers.patch new file mode 100644 index 0000000000000000000000000000000000000000..ae5ee47cf0655bee4d858634cfe40ef0a0737927 --- /dev/null +++ b/backport-CVE-2024-24795-let-httpd-handle-CL-TE-for-non-http-handlers.patch @@ -0,0 +1,221 @@ +From a29723ce1af75eed0813c3717d3f6dee9b405ca8 Mon Sep 17 00:00:00 2001 +From: Eric Covener +Date: Wed, 3 Apr 2024 12:10:49 +0000 +Subject: [PATCH] let httpd handle CL/TE for non-http handlers + +backport r1916769 from trunk: +Submitted By: ylavic, covener + + + +git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1916777 13f79535-47bb-0310-9956-ffa450edef68 + +Conflict:NA +Reference:https://github.com/apache/httpd/commit/a29723ce1af75eed0813c3717d3f6dee9b405ca8 + +--- + include/util_script.h | 2 ++ + modules/aaa/mod_authnz_fcgi.c | 8 ++++++++ + modules/generators/mod_cgi.c | 15 ++++++++++++--- + modules/generators/mod_cgid.c | 15 ++++++++++++--- + modules/http/http_filters.c | 12 ++++++++++++ + modules/proxy/ajp_header.c | 10 ++++++++++ + modules/proxy/mod_proxy_fcgi.c | 9 +++++++++ + modules/proxy/mod_proxy_scgi.c | 8 ++++++++ + modules/proxy/mod_proxy_uwsgi.c | 6 ++++++ + 9 files changed, 79 insertions(+), 6 deletions(-) + +diff --git a/include/util_script.h b/include/util_script.h +index 3566bd3..0557c7f 100644 +--- a/include/util_script.h ++++ b/include/util_script.h +@@ -225,6 +225,8 @@ AP_DECLARE(int) ap_scan_script_header_err_core_ex(request_rec *r, char *buffer, + */ + AP_DECLARE(void) ap_args_to_table(request_rec *r, apr_table_t **table); + ++#define AP_TRUST_CGILIKE_CL_ENVVAR "ap_trust_cgilike_cl" ++ + #ifdef __cplusplus + } + #endif +diff --git a/modules/aaa/mod_authnz_fcgi.c b/modules/aaa/mod_authnz_fcgi.c +index d99f391..d4be53e 100644 +--- a/modules/aaa/mod_authnz_fcgi.c ++++ b/modules/aaa/mod_authnz_fcgi.c +@@ -571,6 +571,14 @@ static apr_status_t handle_response(const fcgi_provider_conf *conf, + "parsing -> %d/%d", + fn, status, r->status); + ++ /* FCGI has its own body framing mechanism which we don't ++ * match against any provided Content-Length, so let the ++ * core determine C-L vs T-E based on what's actually sent. ++ */ ++ if (!apr_table_get(r->subprocess_env, AP_TRUST_CGILIKE_CL_ENVVAR)) ++ apr_table_unset(r->headers_out, "Content-Length"); ++ apr_table_unset(r->headers_out, "Transfer-Encoding"); ++ + if (rspbuf) { /* caller wants to see response body, + * if any + */ +diff --git a/modules/generators/mod_cgi.c b/modules/generators/mod_cgi.c +index 7e4b126..96bb883 100644 +--- a/modules/generators/mod_cgi.c ++++ b/modules/generators/mod_cgi.c +@@ -935,9 +935,18 @@ static int cgi_handler(request_rec *r) + char sbuf[MAX_STRING_LEN]; + int ret; + +- if ((ret = ap_scan_script_header_err_brigade_ex(r, bb, sbuf, +- APLOG_MODULE_INDEX))) +- { ++ ret = ap_scan_script_header_err_brigade_ex(r, bb, sbuf, ++ APLOG_MODULE_INDEX); ++ ++ /* xCGI has its own body framing mechanism which we don't ++ * match against any provided Content-Length, so let the ++ * core determine C-L vs T-E based on what's actually sent. ++ */ ++ if (!apr_table_get(r->subprocess_env, AP_TRUST_CGILIKE_CL_ENVVAR)) ++ apr_table_unset(r->headers_out, "Content-Length"); ++ apr_table_unset(r->headers_out, "Transfer-Encoding"); ++ ++ if (ret != OK) { + ret = log_script(r, conf, ret, dbuf, sbuf, bb, script_err); + + /* +diff --git a/modules/generators/mod_cgid.c b/modules/generators/mod_cgid.c +index 9f4282c..1a67779 100644 +--- a/modules/generators/mod_cgid.c ++++ b/modules/generators/mod_cgid.c +@@ -1614,9 +1614,18 @@ static int cgid_handler(request_rec *r) + b = apr_bucket_eos_create(c->bucket_alloc); + APR_BRIGADE_INSERT_TAIL(bb, b); + +- if ((ret = ap_scan_script_header_err_brigade_ex(r, bb, sbuf, +- APLOG_MODULE_INDEX))) +- { ++ ret = ap_scan_script_header_err_brigade_ex(r, bb, sbuf, ++ APLOG_MODULE_INDEX); ++ ++ /* xCGI has its own body framing mechanism which we don't ++ * match against any provided Content-Length, so let the ++ * core determine C-L vs T-E based on what's actually sent. ++ */ ++ if (!apr_table_get(r->subprocess_env, AP_TRUST_CGILIKE_CL_ENVVAR)) ++ apr_table_unset(r->headers_out, "Content-Length"); ++ apr_table_unset(r->headers_out, "Transfer-Encoding"); ++ ++ if (ret != OK) { + ret = log_script(r, conf, ret, dbuf, sbuf, bb, NULL); + + /* +diff --git a/modules/http/http_filters.c b/modules/http/http_filters.c +index f25d6f0..e9faa2e 100644 +--- a/modules/http/http_filters.c ++++ b/modules/http/http_filters.c +@@ -773,6 +773,18 @@ static APR_INLINE int check_headers(request_rec *r) + struct check_header_ctx ctx; + core_server_config *conf = + ap_get_core_module_config(r->server->module_config); ++ const char *val; ++ ++ if ((val = apr_table_get(r->headers_out, "Transfer-Encoding"))) { ++ if (apr_table_get(r->headers_out, "Content-Length")) { ++ apr_table_unset(r->headers_out, "Content-Length"); ++ r->connection->keepalive = AP_CONN_CLOSE; ++ } ++ if (!ap_is_chunked(r->pool, val)) { ++ r->connection->keepalive = AP_CONN_CLOSE; ++ return 0; ++ } ++ } + + ctx.r = r; + ctx.strict = (conf->http_conformance != AP_HTTP_CONFORMANCE_UNSAFE); +diff --git a/modules/proxy/ajp_header.c b/modules/proxy/ajp_header.c +index 76989c8..c0a2dd7 100644 +--- a/modules/proxy/ajp_header.c ++++ b/modules/proxy/ajp_header.c +@@ -17,6 +17,8 @@ + #include "ajp_header.h" + #include "ajp.h" + ++#include "util_script.h" ++ + APLOG_USE_MODULE(proxy_ajp); + + static const char *response_trans_headers[] = { +@@ -662,6 +664,14 @@ static apr_status_t ajp_unmarshal_response(ajp_msg_t *msg, + } + } + ++ /* AJP has its own body framing mechanism which we don't ++ * match against any provided Content-Length, so let the ++ * core determine C-L vs T-E based on what's actually sent. ++ */ ++ if (!apr_table_get(r->subprocess_env, AP_TRUST_CGILIKE_CL_ENVVAR)) ++ apr_table_unset(r->headers_out, "Content-Length"); ++ apr_table_unset(r->headers_out, "Transfer-Encoding"); ++ + return APR_SUCCESS; + } + +diff --git a/modules/proxy/mod_proxy_fcgi.c b/modules/proxy/mod_proxy_fcgi.c +index 2e97408..08b4c3f 100644 +--- a/modules/proxy/mod_proxy_fcgi.c ++++ b/modules/proxy/mod_proxy_fcgi.c +@@ -735,6 +735,15 @@ recv_again: + + status = ap_scan_script_header_err_brigade_ex(r, ob, + NULL, APLOG_MODULE_INDEX); ++ ++ /* FCGI has its own body framing mechanism which we don't ++ * match against any provided Content-Length, so let the ++ * core determine C-L vs T-E based on what's actually sent. ++ */ ++ if (!apr_table_get(r->subprocess_env, AP_TRUST_CGILIKE_CL_ENVVAR)) ++ apr_table_unset(r->headers_out, "Content-Length"); ++ apr_table_unset(r->headers_out, "Transfer-Encoding"); ++ + /* suck in all the rest */ + if (status != OK) { + apr_bucket *tmp_b; +diff --git a/modules/proxy/mod_proxy_scgi.c b/modules/proxy/mod_proxy_scgi.c +index 11f75de..2a11ef8 100644 +--- a/modules/proxy/mod_proxy_scgi.c ++++ b/modules/proxy/mod_proxy_scgi.c +@@ -388,6 +388,14 @@ static int pass_response(request_rec *r, proxy_conn_rec *conn) + return status; + } + ++ /* SCGI has its own body framing mechanism which we don't ++ * match against any provided Content-Length, so let the ++ * core determine C-L vs T-E based on what's actually sent. ++ */ ++ if (!apr_table_get(r->subprocess_env, AP_TRUST_CGILIKE_CL_ENVVAR)) ++ apr_table_unset(r->headers_out, "Content-Length"); ++ apr_table_unset(r->headers_out, "Transfer-Encoding"); ++ + conf = ap_get_module_config(r->per_dir_config, &proxy_scgi_module); + if (conf->sendfile && conf->sendfile != scgi_sendfile_off) { + short err = 1; +diff --git a/modules/proxy/mod_proxy_uwsgi.c b/modules/proxy/mod_proxy_uwsgi.c +index cc5cda7..e865d04 100644 +--- a/modules/proxy/mod_proxy_uwsgi.c ++++ b/modules/proxy/mod_proxy_uwsgi.c +@@ -382,6 +382,12 @@ static int uwsgi_response(request_rec *r, proxy_conn_rec * backend, + return HTTP_BAD_GATEWAY; + } + ++ /* T-E wins over C-L */ ++ if (apr_table_get(r->headers_out, "Transfer-Encoding")) { ++ apr_table_unset(r->headers_out, "Content-Length"); ++ backend->close = 1; ++ } ++ + if ((buf = apr_table_get(r->headers_out, "Content-Type"))) { + ap_set_content_type(r, apr_pstrdup(r->pool, buf)); + } +-- +2.33.0 + diff --git a/backport-CVE-2024-27316-bail-after-too-many-failed-reads.patch b/backport-CVE-2024-27316-bail-after-too-many-failed-reads.patch new file mode 100644 index 0000000000000000000000000000000000000000..50a1e6a1fe80b2ebd5e2271b577e088fd7dc4c71 --- /dev/null +++ b/backport-CVE-2024-27316-bail-after-too-many-failed-reads.patch @@ -0,0 +1,70 @@ +From 0d73970ec161300a55b630f71bbf72b5c41f28b9 Mon Sep 17 00:00:00 2001 +From: Eric Covener +Date: Wed, 3 Apr 2024 12:12:55 +0000 +Subject: [PATCH] Merge r1916771 from trunk: + +bail after too many failed reads + +Submitted By: icing + + + + +git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1916779 13f79535-47bb-0310-9956-ffa450edef68 + +Conflict:The mod_http2 version upgrade (9767274) and new feature (06ceb22) are not integrated. As a result, context adaptation exists in h2_session.c. +Reference:https://github.com/apache/httpd/commit/0d73970ec161300a55b630f71bbf72b5c41f28b9 + +--- + modules/http2/h2_session.c | 7 ++++++- + modules/http2/h2_stream.c | 1 + + modules/http2/h2_stream.h | 3 ++- + 3 files changed, 9 insertions(+), 2 deletions(-) + +diff --git a/modules/http2/h2_session.c b/modules/http2/h2_session.c +index aa2bf46..445f583 100644 +--- a/modules/http2/h2_session.c ++++ b/modules/http2/h2_session.c +@@ -311,7 +311,12 @@ static int on_header_cb(nghttp2_session *ngh2, const nghttp2_frame *frame, + + status = h2_stream_add_header(stream, (const char *)name, namelen, + (const char *)value, valuelen); +- if (status != APR_SUCCESS && !h2_stream_is_ready(stream)) { ++ if (status != APR_SUCCESS && ++ !h2_stream_is_ready(stream) || ++ /* We accept a certain amount of failures in order to reply ++ * with an informative HTTP error response like 413. But if the ++ * client is too wrong, we fail the request a RESET of the stream */ ++ stream->request_headers_failed > 100) { + return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE; + } + return 0; +diff --git a/modules/http2/h2_stream.c b/modules/http2/h2_stream.c +index 1482086..fad1df1 100644 +--- a/modules/http2/h2_stream.c ++++ b/modules/http2/h2_stream.c +@@ -733,6 +733,7 @@ apr_status_t h2_stream_add_header(h2_stream *stream, + } + + if (error) { ++ ++stream->request_headers_failed; + set_error_response(stream, error); + return APR_EINVAL; + } +diff --git a/modules/http2/h2_stream.h b/modules/http2/h2_stream.h +index 9761ed7..1af1256 100644 +--- a/modules/http2/h2_stream.h ++++ b/modules/http2/h2_stream.h +@@ -75,7 +75,8 @@ struct h2_stream { + struct h2_request *rtmp; /* request being assembled */ + apr_table_t *trailers; /* optional incoming trailers */ + int request_headers_added; /* number of request headers added */ +- ++ int request_headers_failed; /* number of request headers failed to add */ ++ + struct h2_bucket_beam *input; + apr_bucket_brigade *in_buffer; + int in_window_size; +-- +2.33.0 + diff --git a/backport-Fix-use-after-free-warning-with-gcc-fanalyzer.patch b/backport-Fix-use-after-free-warning-with-gcc-fanalyzer.patch new file mode 100644 index 0000000000000000000000000000000000000000..9d0a4785e5eca9b22c315c22e9a38cc22f912c03 --- /dev/null +++ b/backport-Fix-use-after-free-warning-with-gcc-fanalyzer.patch @@ -0,0 +1,74 @@ +From 8fe3cc79d1bcb4a20a0c56853d82e85c8a88b8f5 Mon Sep 17 00:00:00 2001 +From: Graham Leggett +Date: Mon, 20 Nov 2023 13:17:25 +0000 +Subject: [PATCH] Backport to v2.4: + + *) core: Fix use after free warning with gcc -fanalyzer. + trunk patch: http://svn.apache.org/r1892413 + 2.4.x patch: https://svn.apache.org/repos/asf/httpd/httpd/patches/2.4.x/httpd-2.4-use-after-free.patch + +1: minfrin, ylavic, jorton + + + +git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1913983 13f79535-47bb-0310-9956-ffa450edef68 + +Conflict:The changelog contains context adaptation and does not contain the STATUS file +Reference:https://github.com/apache/httpd/commit/8fe3cc79d1bcb4a20a0c56853d82e85c8a88b8f5 + +--- + CHANGES | 2 ++ + server/mpm_unix.c | 16 ++++++++++------ + 2 files changed, 12 insertions(+), 6 deletions(-) + +diff --git a/CHANGES b/CHANGES +index f3f52fd..906667a 100644 +--- a/CHANGES ++++ b/CHANGES +@@ -3,6 +3,8 @@ Changes with Apache 2.4.59 + + *) mod_ssl: release memory to the OS when needed. [Giovanni Bechis] + ++ *) core: Fix use after free warning with gcc -fanalyzer. [Joe Orton] ++ + Changes with Apache 2.4.43 + + *) mod_ssl: Fix memory leak of OCSP stapling response. [Yann Ylavic] +diff --git a/server/mpm_unix.c b/server/mpm_unix.c +index 775fe5f..9c5f45b 100644 +--- a/server/mpm_unix.c ++++ b/server/mpm_unix.c +@@ -259,10 +259,12 @@ AP_DECLARE(void) ap_reclaim_child_processes(int terminate, + while (cur_extra) { + ap_generation_t old_gen; + extra_process_t *next = cur_extra->next; ++ pid_t pid = cur_extra->pid; + +- if (reclaim_one_pid(cur_extra->pid, action_table[cur_action].action)) { +- if (ap_unregister_extra_mpm_process(cur_extra->pid, &old_gen) == 1) { +- mpm_callback(-1, cur_extra->pid, old_gen); ++ if (reclaim_one_pid(pid, action_table[cur_action].action)) { ++ if (ap_unregister_extra_mpm_process(pid, &old_gen) == 1) { ++ /* cur_extra dangling pointer from here. */ ++ mpm_callback(-1, pid, old_gen); + } + else { + AP_DEBUG_ASSERT(1 == 0); +@@ -307,10 +309,12 @@ AP_DECLARE(void) ap_relieve_child_processes(ap_reclaim_callback_fn_t *mpm_callba + while (cur_extra) { + ap_generation_t old_gen; + extra_process_t *next = cur_extra->next; ++ pid_t pid = cur_extra->pid; + +- if (reclaim_one_pid(cur_extra->pid, DO_NOTHING)) { +- if (ap_unregister_extra_mpm_process(cur_extra->pid, &old_gen) == 1) { +- mpm_callback(-1, cur_extra->pid, old_gen); ++ if (reclaim_one_pid(pid, DO_NOTHING)) { ++ if (ap_unregister_extra_mpm_process(pid, &old_gen) == 1) { ++ /* cur_extra dangling pointer from here. */ ++ mpm_callback(-1, pid, old_gen); + } + else { + AP_DEBUG_ASSERT(1 == 0); +-- +2.33.0 + diff --git a/backport-Use-ap_os_is_path_absolute-to-make-it-portable.patch b/backport-Use-ap_os_is_path_absolute-to-make-it-portable.patch new file mode 100644 index 0000000000000000000000000000000000000000..a468867cb89a62212506b75e273b4be0c5a7b6f4 --- /dev/null +++ b/backport-Use-ap_os_is_path_absolute-to-make-it-portable.patch @@ -0,0 +1,55 @@ +From 32881a76e31f8bafa498999bae5237c3a6418317 Mon Sep 17 00:00:00 2001 +From: Jean-Frederic Clere +Date: Wed, 14 Feb 2024 14:27:03 +0000 +Subject: [PATCH] * mod_slotmem_shm: Use ap_os_is_path_absolute() to make it + portable. + +Reviewed by: jfclere, jorton, covener + + + +git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1915791 13f79535-47bb-0310-9956-ffa450edef68 + +Conflict:NA +Reference:https://github.com/apache/httpd/commit/32881a76e31f8bafa498999bae5237c3a6418317 + +--- + changes-entries/mod_slotmem_shm.txt | 3 +++ + modules/slotmem/mod_slotmem_shm.c | 4 ++-- + 2 files changed, 5 insertions(+), 2 deletions(-) + create mode 100644 changes-entries/mod_slotmem_shm.txt + +diff --git a/changes-entries/mod_slotmem_shm.txt b/changes-entries/mod_slotmem_shm.txt +new file mode 100644 +index 0000000..767711f +--- /dev/null ++++ b/changes-entries/mod_slotmem_shm.txt +@@ -0,0 +1,3 @@ ++ *) mod_slotmem_shm: Use ap_os_is_path_absolute() to make it portable. ++ [Jean-Frederic Clere] ++ +diff --git a/modules/slotmem/mod_slotmem_shm.c b/modules/slotmem/mod_slotmem_shm.c +index f4eaa84..4d14faf 100644 +--- a/modules/slotmem/mod_slotmem_shm.c ++++ b/modules/slotmem/mod_slotmem_shm.c +@@ -92,7 +92,7 @@ static int slotmem_filenames(apr_pool_t *pool, + const char *fname = NULL, *pname = NULL; + + if (slotname && *slotname && strcasecmp(slotname, "none") != 0) { +- if (slotname[0] != '/') { ++ if (!ap_os_is_path_absolute(pool, slotname)) { + /* Each generation needs its own file name. */ + int generation = 0; + ap_mpm_query(AP_MPMQ_GENERATION, &generation); +@@ -109,7 +109,7 @@ static int slotmem_filenames(apr_pool_t *pool, + + if (persistname) { + /* Persisted file names are immutable... */ +- if (slotname[0] != '/') { ++ if (!ap_os_is_path_absolute(pool, slotname)) { + pname = apr_pstrcat(pool, DEFAULT_SLOTMEM_PREFIX, + slotname, DEFAULT_SLOTMEM_SUFFIX, + DEFAULT_SLOTMEM_PERSIST_SUFFIX, +-- +2.33.0 + diff --git a/backport-release-memory-to-the-OS-when-needed.patch b/backport-release-memory-to-the-OS-when-needed.patch new file mode 100644 index 0000000000000000000000000000000000000000..ecc0023c099083599d5b00a33d116a0217c1a760 --- /dev/null +++ b/backport-release-memory-to-the-OS-when-needed.patch @@ -0,0 +1,101 @@ +From 80560d29c8bc6dac44c8a7f7767e54e0ec52c5e6 Mon Sep 17 00:00:00 2001 +From: Graham Leggett +Date: Sat, 18 Nov 2023 11:20:14 +0000 +Subject: [PATCH] Backport to v2.4: + + *) mod_ssl: release memory to the OS when needed + Trunk version of patch: + https://svn.apache.org/r1898410 + https://svn.apache.org/r1898366 + svn merge -c 1898366 ^/httpd/httpd/trunk . + svn merge -c 1898410 ^/httpd/httpd/trunk . + +1: gbechis, ylavic, jorton + + + +git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1913909 13f79535-47bb-0310-9956-ffa450edef68 + +Conflict:The changelog contains context adaptation and does not contain the STATUS file +Reference:https://github.com/apache/httpd/commit/80560d29c8bc6dac44c8a7f7767e54e0ec52c5e6 + +--- + CHANGES | 4 ++++ + modules/ssl/ssl_engine_init.c | 7 ++++++- + modules/ssl/ssl_util_ocsp.c | 5 ++++- + modules/ssl/ssl_util_stapling.c | 4 +++- + 4 files changed, 17 insertions(+), 3 deletions(-) + +diff --git a/CHANGES b/CHANGES +index 0a351d1..f3f52fd 100644 +--- a/CHANGES ++++ b/CHANGES +@@ -1,4 +1,8 @@ + -*- coding: utf-8 -*- ++Changes with Apache 2.4.59 ++ ++ *) mod_ssl: release memory to the OS when needed. [Giovanni Bechis] ++ + Changes with Apache 2.4.43 + + *) mod_ssl: Fix memory leak of OCSP stapling response. [Yann Ylavic] +diff --git a/modules/ssl/ssl_engine_init.c b/modules/ssl/ssl_engine_init.c +index 1c5ca97..7809e9d 100644 +--- a/modules/ssl/ssl_engine_init.c ++++ b/modules/ssl/ssl_engine_init.c +@@ -1679,6 +1679,7 @@ static apr_status_t ssl_init_proxy_certs(server_rec *s, + ap_log_error(APLOG_MARK, APLOG_EMERG, 0, s, APLOGNO(02208) + "SSL proxy client cert initialization failed"); + ssl_log_ssl_error(SSLLOG_MARK, APLOG_EMERG, s); ++ sk_X509_INFO_free(sk); + return ssl_die(s); + } + +@@ -1688,7 +1689,11 @@ static apr_status_t ssl_init_proxy_certs(server_rec *s, + int i; + + X509_INFO *inf = sk_X509_INFO_value(pkp->certs, n); +- X509_STORE_CTX_init(sctx, store, inf->x509, NULL); ++ if (!X509_STORE_CTX_init(sctx, store, inf->x509, NULL)) { ++ sk_X509_INFO_free(sk); ++ X509_STORE_CTX_free(sctx); ++ return ssl_die(s); ++ } + + /* Attempt to verify the client cert */ + if (X509_verify_cert(sctx) != 1) { +diff --git a/modules/ssl/ssl_util_ocsp.c b/modules/ssl/ssl_util_ocsp.c +index b66e151..0c141e6 100644 +--- a/modules/ssl/ssl_util_ocsp.c ++++ b/modules/ssl/ssl_util_ocsp.c +@@ -369,8 +369,11 @@ static STACK_OF(X509) *modssl_read_ocsp_certificates(const char *file) + while ((x509 = PEM_read_bio_X509(bio, NULL, NULL, NULL)) != NULL) { + if (!other_certs) { + other_certs = sk_X509_new_null(); +- if (!other_certs) ++ if (!other_certs) { ++ X509_free(x509); ++ BIO_free(bio); + return NULL; ++ } + } + + if (!sk_X509_push(other_certs, x509)) { +diff --git a/modules/ssl/ssl_util_stapling.c b/modules/ssl/ssl_util_stapling.c +index 5b3db6b..b508d7c 100644 +--- a/modules/ssl/ssl_util_stapling.c ++++ b/modules/ssl/ssl_util_stapling.c +@@ -117,8 +117,10 @@ static X509 *stapling_get_issuer(modssl_ctx_t *mctx, X509 *x) + } + + inctx = X509_STORE_CTX_new(); +- if (!X509_STORE_CTX_init(inctx, st, NULL, NULL)) ++ if (!X509_STORE_CTX_init(inctx, st, NULL, NULL)) { ++ X509_STORE_CTX_free(inctx); + return 0; ++ } + if (X509_STORE_CTX_get1_issuer(&issuer, inctx, x) <= 0) + issuer = NULL; + X509_STORE_CTX_cleanup(inctx); +-- +2.33.0 + diff --git a/httpd.spec b/httpd.spec index 94d68b7259d94c5068a3c8ebbd6756b0b4724e79..b2c84caebc7c85ee59904c9839b0a480415657f4 100644 --- a/httpd.spec +++ b/httpd.spec @@ -8,7 +8,7 @@ Name: httpd Summary: Apache HTTP Server Version: 2.4.43 -Release: 23 +Release: 24 License: ASL 2.0 URL: https://httpd.apache.org/ Source0: https://archive.apache.org/dist/httpd/httpd-%{version}.tar.bz2 @@ -109,6 +109,12 @@ Patch55: backport-CVE-2019-17567.patch Patch56: backport-Add-readbuffsize-api.patch Patch57: backport-CVE-2023-31122-out-of-bound-Read.patch Patch58: backport-CVE-2023-45802-improved-early-cleanup-of-stream.patch +Patch59: backport-release-memory-to-the-OS-when-needed.patch +Patch60: backport-Fix-use-after-free-warning-with-gcc-fanalyzer.patch +Patch61: backport-Use-ap_os_is_path_absolute-to-make-it-portable.patch +Patch62: backport-CVE-2024-24795-let-httpd-handle-CL-TE-for-non-http-handlers.patch +Patch63: backport-CVE-2023-38709-header-validation-after-content.patch +Patch64: backport-CVE-2024-27316-bail-after-too-many-failed-reads.patch BuildRequires: gcc autoconf pkgconfig findutils xmlto perl-interpreter perl-generators systemd-devel BuildRequires: zlib-devel libselinux-devel lua-devel brotli-devel @@ -545,6 +551,12 @@ exit $rv %{_rpmconfigdir}/macros.d/macros.httpd %changelog +* Mon May 06 2024 chengyechun - 2.4.43-24 +- Type:CVE +- ID:CVE-2024-24795,CVE-2023-38709,CVE-2024-27316 +- SUG:NA +- DESC:fix CVE-2024-24795,CVE-2023-38709,CVE-2024-27316 and sync some patches from upstream + * Thu Nov 02 2023 chengyechun - 2.4.43-23 - Type:CVE - ID:CVE-2023-31122, CVE-2023-45802