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

Add Better Path Handling #12533

Merged
merged 4 commits into from Jul 2, 2022
Merged

Add Better Path Handling #12533

merged 4 commits into from Jul 2, 2022

Conversation

jkjk822
Copy link
Contributor

@jkjk822 jkjk822 commented Jun 29, 2022

Motivation:

Paths, especially those of the form "//path/to/resource" are handled as "/path/to/resource" by most browsers and servers, but Netty fails on these, parsing them as having an authority.

Modification:

Directly forward the uri when it's a path instead of trying to parse it.

Also clean up isOriginForm/isAsteriskForm as their logic seems to be incorrect (for example, URI#getSchemeSpecificPart() never returns null so they both return false trivially).

Result:

Netty forwards uris unchanged when they look to be in origin or asterisk form.

Directly forward the uri when it's a path instead of trying to parse it.

Also clean up isOriginForm/isAsteriskForm as their logic seems to be incorrect (for example, URI#getSchemeSpecificPart() never returns null so they both return false trivially). They should probably be edited themselves in a later commit (and possibly used again here when correct). Since this was always returning true, it's unclear if authority logic is still correct after this change.
Add tests to ensure request conversion behaves as expected.
@jkjk822 jkjk822 marked this pull request as ready for review June 29, 2022 19:23
@ejona86
Copy link
Member

ejona86 commented Jun 29, 2022

I worked with @jkjk822 on this. The issue is that HTTP/1 request target is not a URI syntax. It is a bare path, or some other forms. A bare path is not the same as a URI. In HTTP/1, //path/to/resource is in origin-form and is a path with two leading slashes, which is rarely done and strange, but permitted. If parsed as a URI, that is a scheme-relative URI with a hostname of "path" and path "/to/resource" (this form of URI was commonly used for http vs https; a link of //github.com/blah will go to http or https depending on how the page was served). Essentially, URI.create() is bogus unless the request target is in absolute-form, so we have to do the checking before URI.create().

This may still be broken for authority-form, but it is no worse than it was previously and at least the code is easier to predict how it will behave.

@chrisvest chrisvest modified the milestone: 4.1.79.Final Jun 29, 2022
Fix test failures. This requires refactoring the authority pathway to
reflect what it was in practice before (though not what the logic
implied).

Specifically, the logic before never set the HTTP2 Authority if the path
was in origin or asterisk form (although due to those methods always
returning false this never affected output).
@jkjk822
Copy link
Contributor Author

jkjk822 commented Jun 30, 2022

Whoops, was running against master locally... Fixed all failures this time.

Note the authority logic as mentioned in the first commit did end up having to be changed to pass tests. If the original logic is correct, the tests should be changed instead.

@normanmaurer
Copy link
Member

@jkjk822 can you please sign our icla: https://netty.io/s/icla ? /cc @ejona86

@jkjk822
Copy link
Contributor Author

jkjk822 commented Jul 1, 2022

CLA signed

@normanmaurer normanmaurer merged commit 7d540fc into netty:4.1 Jul 2, 2022
normanmaurer pushed a commit that referenced this pull request Jul 2, 2022
Motivation:

Paths, especially those of the form "//path/to/resource" are handled as "/path/to/resource" by most browsers and servers, but Netty fails on these, parsing them as having an authority.

Modification:

Directly forward the uri when it's a path instead of trying to parse it.

Also clean up isOriginForm/isAsteriskForm as their logic seems to be incorrect (for example, URI#getSchemeSpecificPart() never returns null so they both return false trivially).

Result:

Netty forwards uris unchanged when they look to be in origin or asterisk form.
raidyue pushed a commit to raidyue/netty that referenced this pull request Jul 8, 2022
Motivation:

Paths, especially those of the form "//path/to/resource" are handled as "/path/to/resource" by most browsers and servers, but Netty fails on these, parsing them as having an authority.

Modification:

Directly forward the uri when it's a path instead of trying to parse it.

Also clean up isOriginForm/isAsteriskForm as their logic seems to be incorrect (for example, URI#getSchemeSpecificPart() never returns null so they both return false trivially).

Result:

Netty forwards uris unchanged when they look to be in origin or asterisk form.
franz1981 pushed a commit to franz1981/netty that referenced this pull request Aug 22, 2022
Motivation:

Paths, especially those of the form "//path/to/resource" are handled as "/path/to/resource" by most browsers and servers, but Netty fails on these, parsing them as having an authority.

Modification:

Directly forward the uri when it's a path instead of trying to parse it.

Also clean up isOriginForm/isAsteriskForm as their logic seems to be incorrect (for example, URI#getSchemeSpecificPart() never returns null so they both return false trivially).

Result:

Netty forwards uris unchanged when they look to be in origin or asterisk form.
DerGuteMoritz added a commit to clj-commons/aleph that referenced this pull request Aug 22, 2022
4.1.77.Final shipped a fix for CVE-2022-24823. While that
vulnerability only affects Java 6 and lower which Clojure doesn't even
support, it's still reported by tools like `nvd-clojure`. Thus,
bumping to the latest minor version relieves downstream users from
having to suppress such false positives.

Also included are various smaller bug fixes and improvements. A
selection of particularly interesting ones for Aleph users:

* netty/netty#12108
* netty/netty#12246
* netty/netty#12270
* netty/netty#12476
* netty/netty#12490
* netty/netty#12533
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants