[
https://issues.apache.org/jira/browse/TS-1570?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14217060#comment-14217060
]
Brian Geffon commented on TS-1570:
----------------------------------
[~cynthiagu], a few comments, firstly we shouldn't really do this validation
during the parsing state we should do it after parsing is complete, that is
after {{parse_req()}} returns {{PARSE_DONE}}. Additionally, we avoid using
{{std::string}} in core code whenever possible. Luckily, you shouldn't need
them anyway. Your checking logic is overly complicated, we can simplify by
simply searching for the host header after parsing and then parsing the host
header rather than searching the entire request string.
Also, you should considering using {{strtol}} for converting the string to an
int as it will return 0 on error anyway. Next, we need to be careful regarding
parsing of the host header in regard to ipv6 addresses. For example, {{Host:
[::1]:443}} is a valid host header and we should be cautious that validation
wouldn't break that case.
An example of retrieving the Host header after parsing would be:
{code}
MIMEField *field =
t_state.hdr_info.server_response.field_find(MIME_FIELD_HOST, MIME_LEN_HOST);
if (field) {
int host_len = 0;
const char *host_hdr = field->value_get(&host_len);
}
{code}
This should ideally all happen during the remap verification phase.
> remap doesn't reject request whose Host has extra characters after port (like
> "test.com:80xxx")
> -----------------------------------------------------------------------------------------------
>
> Key: TS-1570
> URL: https://issues.apache.org/jira/browse/TS-1570
> Project: Traffic Server
> Issue Type: Bug
> Components: HTTP
> Affects Versions: 3.3.0
> Reporter: Conan Wang
> Assignee: Cynthia Gu
> Priority: Minor
> Fix For: 5.3.0
>
> Attachments: patch.diff, patch.diff1
>
>
> remap.config: map http://test.com http://1.1.1.1
> The request with Host: 'test.com:80xxx' or 'test.com:xxx' will get passed.
> Such host is not filtered strictly.
> Just report, didn't have big problem for me though.
> curl http://127.0.0.1:8080/ -H "Host: test.com:80xxx"
> or curl -x 127.0.0.1:8080 http://test.com:80xxx/ -v
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)