Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow_absolute_url causes misleading logs #8078

Closed
snowp opened this issue Aug 29, 2019 · 15 comments
Closed

allow_absolute_url causes misleading logs #8078

snowp opened this issue Aug 29, 2019 · 15 comments
Labels
enhancement Feature requests. Not bugs or questions. stale stalebot believes this issue/PR has not been touched recently

Comments

@snowp
Copy link
Contributor

snowp commented Aug 29, 2019

The allow_aboslute_url option on the http1 codec options on the HCM imply that leaving at the default of false will mean that absolute URLs are not allowed. Instead, what happens is that the url is passed unchanged as the :path header to the HCM, which results in the full URI being used for route matching. As a result, the common idiom of using prefix: / as "match any" doesn't work because it doesn't match the scheme-prefixed URL.

I'm not sure if this warrants any behavioral changes, but at the very least the docs should be clearer about what the implication of this option is. Maybe even renaming it to handle_absolute_url with V3?

Relevant code: https://github.com/envoyproxy/envoy/blob/master/source/common/http/http1/codec_impl.cc#L544-L572

@mattklein123 mattklein123 added no stalebot Disables stalebot from closing an issue api/v3 Major version release @ end of Q3 2019 labels Aug 29, 2019
@mattklein123 mattklein123 added this to the 1.12.0 milestone Aug 29, 2019
@alyssawilk
Copy link
Contributor

I think this may be a bug. I wouldn't expect "http://foo.com" to be a valid path. I think that'd imply we could have a url http://http://foo.com which I'm pretty sure isn't actually valid. I suspect what's happening is that http_parser (which handles absolute urls) is treating it as a url and we don't do path validation because we trust http parser, so I think I should just go ahead and fix this.

@PiotrSikora for sanity checking

@alyssawilk alyssawilk added the bug label Sep 18, 2019
@alyssawilk alyssawilk self-assigned this Sep 18, 2019
@alyssawilk
Copy link
Contributor

Actually @snowp can you talk more to this problem?
https://github.com/envoyproxy/envoy/blob/master/source/common/http/conn_manager_impl.cc#L734
should be rejecting everything that isn't relative.
If allow_absolute_url is on, the h1 codec should be breaking absolute urls into the relative components. If it's off, we should fail checks in decodeHeaders and sendLocalReply.

@PiotrSikora
Copy link
Contributor

http://foo.com (i.e. GET http://foo.com HTTP/1.1) is a valid form (see: RFC7230, sec. 5.3.2).

However, it should be split into :scheme, :authority and :path before it's passed to HCM.

I didn't look at the code, but from what @snowp is saying, it seems that's happening with allow_aboslute_url: true, but with allow_aboslute_url: false (default) everything is passed inside :path instead of being rejected, which is definitely an incorrect behavior.

@alyssawilk
Copy link
Contributor

Right, everything is passed through, and then immediately rejected by the HCM early on in decodeHeaders, as far as I can tell

TEST_P(IntegrationTest, BadPath)
verifies that the link above is blocking
[C1][S11522070672761765734] Sending local reply with details absolute_path_rejected

Snow: is it possible you read the 404 as your matchers not matching rather than the URL being rejected as absolute?

@snowp
Copy link
Contributor Author

snowp commented Sep 18, 2019

We sere seeing the REQ(:path) access log segment display "http://...", which lead to the conclusion that it was the full URL being used as :path when computing the route, so it ended up not matching any of our routes (including our fallback match_prefix: /).

@alyssawilk
Copy link
Contributor

gotcha.
this might lead to confusing access logs, but treating the full url as an invalid path is how absolute url lack-of-support has always been implemented. Even if you match * it's going to 404 due to the linked code.

we could flat out reject it in the codec instead, which AFIK would mean you had no logs data as the stream won't have gotten headers.

@PiotrSikora
Copy link
Contributor

Is there any reason that we don't allow absolute-form by default?

@alyssawilk
Copy link
Contributor

Orthogonal from how to make this behavior less confusing when we disallow:

I'm failing to find where it was added but as I recall it was a high-ish risk PR (we didn't fully trust the url splitting utility) and we didn't yet have runtime overrides, so we made it a config option and defaulted to the old, safe, behavior. There was at least one bug with url parsing (I think it was that query parameters were dropped accidentally?) so it wasn't a terrible call.

Today I would have been inclined to protect it rather than make it configurable. Annoyingly I don't think we can remove the option now that it's there but given it's a BoolValue I don't think it'd be unreasonable to switch the default where it's not configured and add a release note about the switch so folks who want to disallow can explicitly configure it off. Given this is totally legit HTTP/1 I think allowing it by default is the right thing to do. @mattklein123 WDYT? If you agree I'm happy to take that on.

@mattklein123
Copy link
Member

Given this is totally legit HTTP/1 I think allowing it by default is the right thing to do. @mattklein123 WDYT? If you agree I'm happy to take that on.

Sure makes sense to me to default to on at this point.

@alyssawilk alyssawilk removed the bug label Sep 23, 2019
@alyssawilk alyssawilk changed the title allow_absolute_url option misleading allow_absolute_url logs misleading Sep 23, 2019
@alyssawilk alyssawilk changed the title allow_absolute_url logs misleading allow_absolute_url causes misleading logs Sep 23, 2019
@alyssawilk
Copy link
Contributor

I'm going to re-title.
allow_absolute_url absolutely controls if an absolute url is allowed.
The logs are arguably confusing, though if we'd split it up it could be equally confusing why the url which "should match" didn't match (when it wasn't obvious it was absolute). Less sure what to do about that.

alyssawilk added a commit that referenced this issue Sep 23, 2019
As discussed on #8078 absolute URLs are part of the HTTP/1 spec and the code has been used for some time now - turning it up by default.

Risk Level: Medium (changes to L7 for many users)
Testing: updated tests for new defaults
Docs Changes: no
Release Notes: yes

Signed-off-by: Alyssa Wilk <[email protected]>
@PiotrSikora
Copy link
Contributor

REQ(:path) and others should log the same value regardless of what form was used, i.e.:

GET http://foo.com HTTP/1.1
GET / HTTP/1.1
Host: foo.com

should evaluate REQ(:path) to / in both cases.

danzh2010 pushed a commit to danzh2010/envoy that referenced this issue Sep 24, 2019
As discussed on envoyproxy#8078 absolute URLs are part of the HTTP/1 spec and the code has been used for some time now - turning it up by default.

Risk Level: Medium (changes to L7 for many users)
Testing: updated tests for new defaults
Docs Changes: no
Release Notes: yes

Signed-off-by: Alyssa Wilk <[email protected]>
@htuch
Copy link
Member

htuch commented Sep 26, 2019

Is this still a v3 API renaming ask or should we remove the label?

@alyssawilk alyssawilk removed the api/v3 Major version release @ end of Q3 2019 label Sep 26, 2019
@alyssawilk
Copy link
Contributor

I think it's a code fix not an API fix. label updated.

danzh2010 pushed a commit to danzh2010/envoy that referenced this issue Oct 4, 2019
As discussed on envoyproxy#8078 absolute URLs are part of the HTTP/1 spec and the code has been used for some time now - turning it up by default.

Risk Level: Medium (changes to L7 for many users)
Testing: updated tests for new defaults
Docs Changes: no
Release Notes: yes

Signed-off-by: Alyssa Wilk <[email protected]>
danzh2010 pushed a commit to danzh2010/envoy that referenced this issue Oct 4, 2019
As discussed on envoyproxy#8078 absolute URLs are part of the HTTP/1 spec and the code has been used for some time now - turning it up by default.

Risk Level: Medium (changes to L7 for many users)
Testing: updated tests for new defaults
Docs Changes: no
Release Notes: yes

Signed-off-by: Alyssa Wilk <[email protected]>
@mattklein123 mattklein123 added the enhancement Feature requests. Not bugs or questions. label Oct 10, 2019
@alyssawilk alyssawilk removed their assignment Oct 16, 2019
@mattklein123 mattklein123 removed this from the 1.12.0 milestone Oct 17, 2019
@mattklein123 mattklein123 added this to the 1.13.0 milestone Oct 17, 2019
@mattklein123 mattklein123 modified the milestones: 1.13.0, 1.14.0 Dec 6, 2019
@mattklein123 mattklein123 removed this from the 1.14.0 milestone Mar 18, 2020
@alyssawilk alyssawilk removed the no stalebot Disables stalebot from closing an issue label Oct 8, 2024
Copy link

github-actions bot commented Nov 7, 2024

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale stalebot believes this issue/PR has not been touched recently label Nov 7, 2024
Copy link

This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature requests. Not bugs or questions. stale stalebot believes this issue/PR has not been touched recently
Projects
None yet
Development

No branches or pull requests

5 participants