-
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
UriCompliance.Violation ignored despite being set #11448
Comments
Okay thanks, I will retest as soon as the PR is included in the next version and will close this after verifying it works as expected. |
@puskarpeter do you have an example spring-boot project that can demonstrate this reported issue? |
Here is minimal reproducer for both Jetty 11 and 12 to compare their behavior: |
Thank you for your demo project. So here's what's happening. The Spring HttpClient is encoding the On the network, the path is received as Eventually, it reaches Jersey's ServletContainer and the following stacktrace occurs.
This is coming from the following piece of code... Lines 195 to 209 in 2803f5a
This kind of URI path is actually tripping over many things around path encoding and decoding in the Servlet spec. Not sure if we can support / allow these kinds of ambiguous URLs through safely into the Servlet spec APIs. |
How you construct your Take this updated testcase for Jetty12 That shows the same HTTP endpoint being accessed via 5 different URI construction techniques, using 2 different HTTP clients. First thing you'll notice is that the The next thing you'll see is that the Jersey If you construct your URI properly, and send it via an HttpClient that doesn't encode before sending the Path then you'll get the results you want. A passing test! Otherwise you'll wind up with |
This is still possible, and the updated testcases show this is possible. You just have to be extra careful how you test it. |
Thanks for pointing out this double encoding problem, I guess that also might be the case in our integration test suite then, as we are invoking the requests via |
@gregw at a minimum I think we should double check the error handling presentation of URIs. The error text this triggers reads as following (for
This is actually the correct on-network raw URI path. |
Why was this closed? I get that the message is now improved but to me, it seems that it is still ignoring the configured violation modes, I even tried the UNSAFE and LEGACY and it still fails with 400 from various HTTP clients (Java, Python, Postman, curl). Also in that test case, you are doing POST request for GET endpoint, not sure if that is also in spec and does not cause any problems. Thanks |
Sorry, it was automatic from merging PR #11457 |
Warning! The following is a Terrible Idea!@puskarpeter see the latest changes to your Servlet 6 (Jetty 12 / ee10) clarified a ton of vague language and behaviors around a bunch of core concepts. If you want to work in Servlet 6, and want to send something like "%2F" then don't use that in the path section of the URI, use it in the query section. To summarize, Servlet 6 has changed how the URI path section works (for encoding / decoding / path parameters / normalization / equivalence / etc) The following APIs are impacted.
The first 4 APIs in that list are critical for proper operation of Jersey, you really do not want to mess with them in the technique demonstated in the above git repository. For more information, see Servlet 6 changes around URI path (encoding / decoding / normalization / equivalence / etc): |
You are correct, I just read it here:
I guess Jersey is first to follow the suit with strict parsing since in MVC it still works (I pushed an example into my repo) |
For others that find this issue in the future, here's the Servlet 6 Spec documentation. See 3.5.2. URI Path Canonicalization and point 10 in that section in particular. |
I think this issue can be closed now? |
Yes, it can be closed. |
- Add `org.eclipse.jetty.UriComplianceMode` option - Possible values are: DEFAULT, LEGACY, RFC3986, UNAMBIGUOUS, UNSAFE - When UNSAFE or LEGACY is used, also apply workaround as suggested in jetty/jetty.project#11448 (comment). This is not Servlet API 6 compliant though, so use on your own risk.
* FELIX-6698 Ability to configure URI Compliance mode - Add `org.eclipse.jetty.UriComplianceMode` option - Possible values are: DEFAULT, LEGACY, RFC3986, UNAMBIGUOUS, UNSAFE - When UNSAFE or LEGACY is used, also apply workaround as suggested in jetty/jetty.project#11448 (comment). This is not Servlet API 6 compliant though, so use on your own risk. * FELIX-6698 Ability to configure URI Compliance mode - Add UNAMBIGUOUS * Code review comments * Code review comments
Jetty version(s)
12.0.6
Jetty Environment
ee10
Java version/vendor
(use: java -version)
openjdk 17.0.10 2024-01-16
OpenJDK Runtime Environment Temurin-17.0.10+7 (build 17.0.10+7)
OpenJDK 64-Bit Server VM Temurin-17.0.10+7 (build 17.0.10+7, mixed mode, sharing)
OS type/version
Ubuntu 22.04 LTS
Description
Jetty throws
Error 400 Ambiguous URI encoding
despite the violation being configured to be ignored.How to reproduce?
Spring Boot 3.2.3 app using spring-boot-starter-jersey with embedded jetty.
Configure Jetty like so:
Sample endpoint:
Then call
curl --location 'http://localhost:8080/foo=bar%2F1'
Even though the configuration is in place, I still get
400: Ambiguous URI encoding
due to the %2F used in the URI. I expected this to pass as it previously did on Jetty 11 with default behavior which had the same set of violations.Now I was able to see in the debugger that this method returns null on the request as I believe it should:
But the Servlet still throws away the request and returns the following:
I can provided more information if needed. Thanks for the help in advance.
The text was updated successfully, but these errors were encountered: