-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Encode control characters in URIUtil.encodePath #6870
Labels
Bug
For general bugs on Jetty side
Comments
gregw
added a commit
that referenced
this issue
Sep 20, 2021
Reproduce #6870 Rewritten Balancer Signed-off-by: Greg Wilkins <gregw@webtide.com>
gregw
added a commit
that referenced
this issue
Sep 20, 2021
Fix #6870 URIUtil.encodePath encodes control characters Signed-off-by: Greg Wilkins <gregw@webtide.com>
gregw
changed the title
Jetty BalancerServlet responds with 500 Server Error when URL contains encoded control characters.
Encode control characters in URIUtil.encodePath
Sep 20, 2021
gregw
added a commit
that referenced
this issue
Sep 21, 2021
This is merged for 9.4.x |
gregw
added a commit
that referenced
this issue
Sep 23, 2021
Doh! created branch but forgot to push.... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Jetty version(s)
9.4.43 and 10.0.1
Description
Runing Jetty with DefaultServlet,
http://localhost/%0A
returns a 404 - as expected.However, when using BalancerServlet, the same request URL causes a 500 error. Same goes for anything from %01 to %1F (i.e. encoded control characters).
By simplifying to a minimal example, it turns out the issue does not occur without the rewrite module enabled.
More specifically, it still doesn't occur if only a RewriteHandler has been added, but adding a VirtualHostRuleContainer triggers it, whether or not there are rules within that container.
Based on the exception, something is decoding the request URL before it is being passed to a URI.create() call, but given that
http://localhost/%20
does NOT trigger the error, it's also being partially re-encoded (otherwise URI.create would complain about the space character, which it doesn't).So, looking at the code, the bug will most likely be in
URIUtil.encodePath
- perhaps the(c < 0)
should be a(c < 20)
or(c < 32 )
? (either way, looks to me like that function could be cleaned up).There may also be a secondary issue - is
RuleContainer.apply
being called when it doesn't need to be?(if the container is either empty, or the virtualhosts don't match the current request, it should be a no-op?)
How to reproduce?
Bash script demonstrating the issue:
Related exception:
/end
The text was updated successfully, but these errors were encountered: