You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by GitBox <gi...@apache.org> on 2022/09/20 08:21:26 UTC
[GitHub] [trafficserver] maskit opened a new pull request, #9100: Validate request-target
maskit opened a new pull request, #9100:
URL: https://github.com/apache/trafficserver/pull/9100
This should fixes https://github.com/apache/trafficserver/issues/9094.
The validation is not very strict. It still allows "authority-form" that doesn't have a port number, but I think it's enough for #9094 and I didn't want to make it overly strict.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] maskit commented on a diff in pull request #9100: Validate request-target
Posted by GitBox <gi...@apache.org>.
maskit commented on code in PR #9100:
URL: https://github.com/apache/trafficserver/pull/9100#discussion_r975467079
##########
proxy/hdrs/HTTP.cc:
##########
@@ -1163,6 +1169,37 @@ http_parser_parse_req(HTTPParser *parser, HdrHeap *heap, HTTPHdrImpl *hh, const
return ret;
}
+ParseResult
+validate_hdr_request_target(int method_wk_idx, URLImpl *url)
+{
+ ParseResult ret = PARSE_RESULT_DONE;
+ int host_len;
+ url->get_host(&host_len);
+ int path_len;
+ const char *path = url->get_path(&path_len);
+ int scheme_len;
+ url->get_scheme(&scheme_len);
+
+ if (host_len == 0) {
+ if (path_len == 1 && path[0] == '*') { // asterisk-form
+ // Skip this check for now because URLImpl can't distinguish '*' and '/*'
+ // if (method_wk_idx != HTTP_WKSIDX_OPTIONS) {
+ // ret = PARSE_RESULT_ERROR;
+ // }
+ } else { // origin-form
+ // Nothing to check here
+ }
+ } else if (scheme_len == 0 && host_len != 0) { // authority-form
+ if (method_wk_idx != HTTP_WKSIDX_CONNECT) {
+ ret = PARSE_RESULT_ERROR;
+ }
+ } else { // absolute-form
+ // Nothing to check here
Review Comment:
We can't check `path[0] == '/'` unfortunately because `path` is `""` and `path_len` is `0` if the request is for `/`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] jvgutierrez commented on a diff in pull request #9100: Validate request-target
Posted by GitBox <gi...@apache.org>.
jvgutierrez commented on code in PR #9100:
URL: https://github.com/apache/trafficserver/pull/9100#discussion_r975749135
##########
proxy/hdrs/HTTP.cc:
##########
@@ -1163,6 +1169,37 @@ http_parser_parse_req(HTTPParser *parser, HdrHeap *heap, HTTPHdrImpl *hh, const
return ret;
}
+ParseResult
+validate_hdr_request_target(int method_wk_idx, URLImpl *url)
+{
+ ParseResult ret = PARSE_RESULT_DONE;
+ int host_len;
+ url->get_host(&host_len);
+ int path_len;
+ const char *path = url->get_path(&path_len);
+ int scheme_len;
+ url->get_scheme(&scheme_len);
+
+ if (host_len == 0) {
+ if (path_len == 1 && path[0] == '*') { // asterisk-form
+ // Skip this check for now because URLImpl can't distinguish '*' and '/*'
+ // if (method_wk_idx != HTTP_WKSIDX_OPTIONS) {
+ // ret = PARSE_RESULT_ERROR;
+ // }
+ } else { // origin-form
+ // Nothing to check here
+ }
+ } else if (scheme_len == 0 && host_len != 0) { // authority-form
+ if (method_wk_idx != HTTP_WKSIDX_CONNECT) {
+ ret = PARSE_RESULT_ERROR;
+ }
+ } else { // absolute-form
+ // Nothing to check here
Review Comment:
oh, understood!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] bryancall commented on pull request #9100: Validate request-target
Posted by GitBox <gi...@apache.org>.
bryancall commented on PR #9100:
URL: https://github.com/apache/trafficserver/pull/9100#issuecomment-1347005356
Cherry picked to 9.1.x
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] maskit commented on a diff in pull request #9100: Validate request-target
Posted by GitBox <gi...@apache.org>.
maskit commented on code in PR #9100:
URL: https://github.com/apache/trafficserver/pull/9100#discussion_r975043875
##########
proxy/hdrs/HTTP.cc:
##########
@@ -1163,6 +1169,37 @@ http_parser_parse_req(HTTPParser *parser, HdrHeap *heap, HTTPHdrImpl *hh, const
return ret;
}
+ParseResult
+validate_hdr_request_target(int method_wk_idx, URLImpl *url)
+{
+ ParseResult ret = PARSE_RESULT_DONE;
+ int host_len;
+ url->get_host(&host_len);
+ int path_len;
+ const char *path = url->get_path(&path_len);
+ int scheme_len;
+ url->get_scheme(&scheme_len);
+
+ if (host_len == 0) {
+ if (path_len == 1 && path[0] == '*') { // asterisk-form
+ // Skip this check for now because URLImpl can't distinguish '*' and '/*'
+ // if (method_wk_idx != HTTP_WKSIDX_OPTIONS) {
Review Comment:
I have an additional patch to enable this check, but I excluded it because some people may not like it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] jvgutierrez commented on a diff in pull request #9100: Validate request-target
Posted by GitBox <gi...@apache.org>.
jvgutierrez commented on code in PR #9100:
URL: https://github.com/apache/trafficserver/pull/9100#discussion_r975068743
##########
proxy/hdrs/HTTP.cc:
##########
@@ -1163,6 +1169,37 @@ http_parser_parse_req(HTTPParser *parser, HdrHeap *heap, HTTPHdrImpl *hh, const
return ret;
}
+ParseResult
+validate_hdr_request_target(int method_wk_idx, URLImpl *url)
+{
+ ParseResult ret = PARSE_RESULT_DONE;
+ int host_len;
+ url->get_host(&host_len);
+ int path_len;
+ const char *path = url->get_path(&path_len);
+ int scheme_len;
+ url->get_scheme(&scheme_len);
+
+ if (host_len == 0) {
+ if (path_len == 1 && path[0] == '*') { // asterisk-form
+ // Skip this check for now because URLImpl can't distinguish '*' and '/*'
+ // if (method_wk_idx != HTTP_WKSIDX_OPTIONS) {
+ // ret = PARSE_RESULT_ERROR;
+ // }
+ } else { // origin-form
+ // Nothing to check here
+ }
+ } else if (scheme_len == 0 && host_len != 0) { // authority-form
+ if (method_wk_idx != HTTP_WKSIDX_CONNECT) {
+ ret = PARSE_RESULT_ERROR;
+ }
+ } else { // absolute-form
+ // Nothing to check here
Review Comment:
maybe it's redundant but could we double check here that `path[0] == '/'` as it's the very defining characteristic of the absolute-form per RFC 9112?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] jvgutierrez commented on a diff in pull request #9100: Validate request-target
Posted by GitBox <gi...@apache.org>.
jvgutierrez commented on code in PR #9100:
URL: https://github.com/apache/trafficserver/pull/9100#discussion_r975068743
##########
proxy/hdrs/HTTP.cc:
##########
@@ -1163,6 +1169,37 @@ http_parser_parse_req(HTTPParser *parser, HdrHeap *heap, HTTPHdrImpl *hh, const
return ret;
}
+ParseResult
+validate_hdr_request_target(int method_wk_idx, URLImpl *url)
+{
+ ParseResult ret = PARSE_RESULT_DONE;
+ int host_len;
+ url->get_host(&host_len);
+ int path_len;
+ const char *path = url->get_path(&path_len);
+ int scheme_len;
+ url->get_scheme(&scheme_len);
+
+ if (host_len == 0) {
+ if (path_len == 1 && path[0] == '*') { // asterisk-form
+ // Skip this check for now because URLImpl can't distinguish '*' and '/*'
+ // if (method_wk_idx != HTTP_WKSIDX_OPTIONS) {
+ // ret = PARSE_RESULT_ERROR;
+ // }
+ } else { // origin-form
+ // Nothing to check here
+ }
+ } else if (scheme_len == 0 && host_len != 0) { // authority-form
+ if (method_wk_idx != HTTP_WKSIDX_CONNECT) {
+ ret = PARSE_RESULT_ERROR;
+ }
+ } else { // absolute-form
+ // Nothing to check here
Review Comment:
maybe it's redundant but could we double check here that `path[0] == '/'` as it's the very defining characteristic of the absolute-form per RFC 9112 && 9110?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] maskit merged pull request #9100: Validate request-target
Posted by GitBox <gi...@apache.org>.
maskit merged PR #9100:
URL: https://github.com/apache/trafficserver/pull/9100
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] zwoop commented on pull request #9100: Validate request-target
Posted by GitBox <gi...@apache.org>.
zwoop commented on PR #9100:
URL: https://github.com/apache/trafficserver/pull/9100#issuecomment-1352356701
Cherry-picked to v9.2.x
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org