Skip to content

Commit

Permalink
Merge r1908095 from trunk:
Browse files Browse the repository at this point in the history
    don't forward invalid query strings

    Submitted by: rpluem

Reviewed By:  covener, fielding, rpluem, gbechis



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1908096 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
covener committed Mar 5, 2023
1 parent d753ea7 commit 8789f6b
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 0 deletions.
10 changes: 10 additions & 0 deletions modules/http2/mod_proxy_http2.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@ static int proxy_http2_canon(request_rec *r, char *url)
path = ap_proxy_canonenc(r->pool, url, (int)strlen(url),
enc_path, 0, r->proxyreq);
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()
"To be forwarded query string contains control "
"characters or spaces");
return HTTP_FORBIDDEN;
}
}
break;
case PROXYREQ_PROXY:
Expand Down
22 changes: 22 additions & 0 deletions modules/mappers/mod_rewrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -4729,6 +4729,17 @@ static int hook_uri2file(request_rec *r)
unsigned skip;
apr_size_t flen;

if (r->args && *(ap_scan_vchar_obstext(r->args))) {
/*
* 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(10410)
"Rewritten query string contains control "
"characters or spaces");
return HTTP_FORBIDDEN;
}

if (ACTION_STATUS == rulestatus) {
int n = r->status;

Expand Down Expand Up @@ -5013,6 +5024,17 @@ static int hook_fixup(request_rec *r)
if (rulestatus) {
unsigned skip;

if (r->args && *(ap_scan_vchar_obstext(r->args))) {
/*
* 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(10411)
"Rewritten query string contains control "
"characters or spaces");
return HTTP_FORBIDDEN;
}

if (ACTION_STATUS == rulestatus) {
int n = r->status;

Expand Down
10 changes: 10 additions & 0 deletions modules/proxy/mod_proxy_ajp.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ static int proxy_ajp_canon(request_rec *r, char *url)
path = ap_proxy_canonenc(r->pool, url, strlen(url), enc_path, 0,
r->proxyreq);
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(10406)
"To be forwarded query string contains control "
"characters or spaces");
return HTTP_FORBIDDEN;
}
}
if (path == NULL)
return HTTP_BAD_REQUEST;
Expand Down
10 changes: 10 additions & 0 deletions modules/proxy/mod_proxy_balancer.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ static int proxy_balancer_canon(request_rec *r, char *url)
path = ap_proxy_canonenc(r->pool, url, strlen(url), enc_path, 0,
r->proxyreq);
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(10407)
"To be forwarded query string contains control "
"characters or spaces");
return HTTP_FORBIDDEN;
}
}
if (path == NULL)
return HTTP_BAD_REQUEST;
Expand Down
10 changes: 10 additions & 0 deletions modules/proxy/mod_proxy_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ static int proxy_http_canon(request_rec *r, char *url)
path = ap_proxy_canonenc(r->pool, url, strlen(url),
enc_path, 0, r->proxyreq);
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:
Expand Down
10 changes: 10 additions & 0 deletions modules/proxy/mod_proxy_wstunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ static int proxy_wstunnel_canon(request_rec *r, char *url)
path = ap_proxy_canonenc(r->pool, url, strlen(url), enc_path, 0,
r->proxyreq);
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(10409)
"To be forwarded query string contains control "
"characters or spaces");
return HTTP_FORBIDDEN;
}
}
if (path == NULL)
return HTTP_BAD_REQUEST;
Expand Down

0 comments on commit 8789f6b

Please sign in to comment.