Skip to content

Commit bd61fb9

Browse files
committed
mod_dav: Fix security issue in unreleased MS-WDV support:
* modules/dav/main/ms_wdv.c (mswdv_combined_proppatch): The MS-WDV combined PROPPATCH handler reads a 16-byte hex length prefix from the request body and uses it directly for memory allocation without bounds checking. An attacker can specify an extremely large value to trigger OOM and crash the worker process. This patch validates the parsed length against LimitXMLRequestBody and APR_SIZE_MAX before allocation. Reported by: Pavel Kohout, Aisle Research, www.aisle.com Submitted by: Pavel Kohout, jorton Github: closes #592 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1931148 13f79535-47bb-0310-9956-ffa450edef68
1 parent 9d74906 commit bd61fb9

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

modules/dav/main/ms_wdv.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "http_protocol.h"
77
#include "http_request.h"
88
#include "http_log.h"
9+
#include "http_core.h"
910

1011
#include "mod_dav.h"
1112

@@ -589,7 +590,7 @@ static dav_error *mswdv_combined_proppatch(request_rec *r)
589590
apr_bucket_brigade *bb;
590591
apr_status_t status;
591592
apr_size_t len = 16;
592-
apr_off_t proppatch_len;
593+
apr_off_t proppatch_len, limit;
593594
char proppatch_len_str[16 + 1];
594595
char *proppatch_data;
595596

@@ -618,6 +619,17 @@ static dav_error *mswdv_combined_proppatch(request_rec *r)
618619
return dav_new_error(r->pool, HTTP_BAD_REQUEST, 0, status,
619620
"Bad PROPPATCH part length");
620621

622+
/* Validate PROPPATCH length against configured limits */
623+
limit = ap_get_limit_xml_body(r);
624+
if (limit > 0 && proppatch_len > limit) {
625+
return dav_new_error(r->pool, HTTP_REQUEST_ENTITY_TOO_LARGE, 0, 0,
626+
"PROPPATCH part length exceeds configured limit");
627+
}
628+
if (proppatch_len <= 0 || proppatch_len > (apr_off_t)APR_SIZE_MAX) {
629+
return dav_new_error(r->pool, HTTP_REQUEST_ENTITY_TOO_LARGE, 0, 0,
630+
"PROPPATCH part length invalid or too large");
631+
}
632+
621633
apr_brigade_destroy(bb);
622634

623635
bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);

0 commit comments

Comments
 (0)