Reject HTTP CONNECT method with no port after colon
Some checks failed
buildbot / buildbot (push) Has been cancelled

This commit is contained in:
Sergey Kandaurov 2026-05-08 19:38:43 +04:00 committed by Sergey Kandaurov
parent 631bfa194d
commit a43c76b4e3

View file

@ -120,6 +120,7 @@ ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b)
sw_host,
sw_host_end,
sw_host_ip_literal,
sw_port_start,
sw_port,
sw_after_slash_in_uri,
sw_check_uri,
@ -388,7 +389,7 @@ ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b)
case sw_host_end:
if (ch == ':') {
state = sw_port;
state = sw_port_start;
break;
}
@ -464,6 +465,19 @@ ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b)
}
break;
case sw_port_start:
state = sw_port;
if (ch >= '0' && ch <= '9') {
break;
}
if (r->method == NGX_HTTP_CONNECT) {
return NGX_HTTP_PARSE_INVALID_REQUEST;
}
/* fall through */
case sw_port:
if (ch >= '0' && ch <= '9') {
break;