Conversation
…, and add it by default to new domains, so both Grizzly and Payara behavior is aligned.
Contributor
|
Thank you, @lprimak, for this fix! You are awesome! ❤️ |
Member
|
I can see on the Grizzly PR a similar comment has been made though suggesting it use a |
…o `org.glassfish.grizzly.http.util.HttpRequestURIDecoder.ALLOW_BACKSLASH`
Contributor
Author
|
@Pandrex247 This has been done. Got an approval for Grizzly PR as well. Thank you!
|
Contributor
Author
|
Grizzly PR has been merged! |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #8142
Description
Requests whose path contains a percent-encoded backslash (
%5C) fail with400 Invalid URI, because Grizzly'sHttpRequestURIDecoderdecodes the URI before normalizing it and then rejects the resulting\. A JAX-RS path parameter carrying JSON with escaped quotes is enough to trigger it. The same application works on standalone Jersey, which never runs Grizzly's decoder.The Grizzly side is fixed in eclipse-ee4j/glassfish-grizzly#2316 by making the check opt-in via the
org.glassfish.grizzly.http.util.HttpRequestURIDecoder.ALLOW_BACKSLASHsystem property: when set, a decoded backslash is kept as path data (RFC 3986) instead of being rejected or rewritten to/. A literal, unencoded\in the request line is still rejected.Changes
org.glassfish.grizzly.http.util.HttpRequestURIDecoder.ALLOW_BACKSLASH=truein both domain templates (gf_template,gf_template_web), forserver-configanddefault-config, so new domains get RFC-correct behavior out of the box.CoyoteAdapter.ALLOW_BACKSLASHnow also honorsorg.glassfish.grizzly.http.util.HttpRequestURIDecoder.ALLOW_BACKSLASH, in addition to the legacyorg.glassfish.grizzly.tcp.tomcat5.CoyoteAdapter.ALLOW_BACKSLASH, so the Tomcat-compat normalization path and Grizzly's agree on one switch.Security note
Why this is safe to enable by default
StandardContextValve.normalize()already treats\as a path separator when evaluating the/WEB-INFand/META-INFguard, and rejects any path that resolves above the context root. So..%5C..%5CWEB-INF%5Cweb.xmlis refused before it reaches the default servlet (verified: 404), and a backslash traversal is bounded exactly like a slash one. The decoded request path itself is not rewritten —\still reaches the application as data. A literal, unencoded\in the request line remains rejected by Grizzly regardless of this setting.Existing domains
Domain templates only affect newly created domains. Upgraded installations keep the old behavior unless they opt in:
Setting the property to
false(or removing it) restores the previous behavior.Important Info
Dependency on Grizzly
This change is inert until Payara consumes a Grizzly release containing eclipse-ee4j/glassfish-grizzly#2318, which makes
HttpRequestURIDecoderhonororg.glassfish.grizzly.http.util.HttpRequestURIDecoder.ALLOW_BACKSLASH. Until then,%5Cis still rejected by Grizzly before the request reachesCoyoteAdapter, and the property has no effect — so merging in either order is safe, but this PR does not resolve #8142 on its own.Testing
Reproducer at https://github.com/flowlogix/backslash-rest-reproducer
Against a JAX-RS echo resource with
curl --path-as-is:/echo/foo%5Cbarfoo\bar/echo/a%5C..%5Cba\..\b/echo/foo\bar(literal)/echo/..%5C..%5CWEB-INF/echo/../WEB-INF/web.xmlTesting Environment
Any
Documentation
TBD: The new
org.glassfish.grizzly.http.util.HttpRequestURIDecoder.ALLOW_BACKSLASHneeds to be documentedNotes for the reviewers:
This PR can be merged now, and when Grizzly is updated, the changes will take effect.
There is no specific order of merging this PR vs. Grizzly PR.