1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-08 15:02:10 +03:00

mod_proxy: Check for space/ctrls in nocanon path/urls before forwarding.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1908827 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yann Ylavic
2023-03-31 00:11:02 +00:00
parent 0a9193072a
commit 2eceb6a9fe
7 changed files with 101 additions and 48 deletions

View File

@@ -128,26 +128,32 @@ static int proxy_http_canon(request_rec *r, char *url)
path = ap_proxy_canonenc_ex(r->pool, url, strlen(url), enc_path,
flags, r->proxyreq);
if (!path) {
return HTTP_BAD_REQUEST;
}
search = r->args;
}
if (search && *ap_scan_vchar_obstext(search)) {
/*
* We have a raw control character or a ' ' in r->args.
* Correct encoding was missed.
*/
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(10408)
"To be forwarded query string contains control "
"characters or spaces");
return HTTP_FORBIDDEN;
}
break;
case PROXYREQ_PROXY:
path = url;
break;
}
if (path == NULL)
return HTTP_BAD_REQUEST;
/*
* If we have a raw control character or a ' ' in nocanon path or
* r->args, correct encoding was missed.
*/
if (path == url && *ap_scan_vchar_obstext(path)) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(10415)
"To be forwarded path contains control "
"characters or spaces");
return HTTP_FORBIDDEN;
}
if (search && *ap_scan_vchar_obstext(search)) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(10408)
"To be forwarded query string contains control "
"characters or spaces");
return HTTP_FORBIDDEN;
}
if (port != def_port)
apr_snprintf(sport, sizeof(sport), ":%d", port);