You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Introduce ability to decode and/or canonicalize URIs in a RewriteRule #13190
Enhancement Description
When running under a UriCompliance mode that allows for ambiguous path behaviors, the path still cannot reach ee10 (Servlet 6) endpoints due to the Servlet 6 rules against ambiguous paths.
There exists a feature on WebAppContext.getServletHandler().setDecodeAmbiguousURIs(true) to decode the path once it reaches that specific WebAppContext.
What is needed is a more general rule for decoding, one that can be applied during Jetty RewriteHandler, so that it can be applied before other rewrite rules, and for cross context dispatching, and even to use it in conjunction with the existing CompactPathRule.
So I propose we create a new DecodeAmbiguousPathCharactersRule that will simply decode any pct-encoded sequence in the path provided, being careful to not decode pct-encoded characters that change the parsing rules for things like query section and path parameters: %3F (?) and %3B (;).
Another approach would be a DecodedCanonicalizedPathRule which just performs the URIUtil.decodePath() and URIUtil.canonicalizedPath() behaviors against the path provided. (have to be careful of the name on this alternate approach, as the definition of canonicalized vs normalized paths has changed in 12.0/12.1)
Also, we have seen custom rules in the wild to match against various known vulnerability scanning behaviors from rogue clients, and reject those request.
These kinds of rules have been verbose and tricky to write, but if they existed after this new proposed rule, many of the variants of rule matching would be much simpler to match against, probably even eliminating many variants of regex / patterns used.
@joakime I'm wondering if just a rule would be good enough. A rule would just correct forever. If it was put in a handler, then it could have more nuanced handling. Ideally you'd want to have a mechanism to wean bad clients off those bad URI's. So at some stage it needs to reject them with a 400 bad request message, perhaps with some instructions on how to request and exemption that can be put into their session and/or user data.
setDecoding(boolean) - false by default, true to run decodePath
setCanonicalizing(boolean) - false by default, true to run canonicalizePath
addListener(Listener) - optional listener to get notified when a compactPath rule changed the path.
This is where a user can add their own audit logging to record where bad clients are coming from, and approach those bad clients to get them to change their behaviors in the future.
changed the title [-]Introduce `DecodeAmbiguousPathCharactersRule`[/-][+]Introduce ability to decode and/or canonicalize URIs in a RewriteRule[/+]on Jun 25, 2025
Activity
joakime commentedon May 30, 2025
@gregw what are your thoughts on this?
joakime commentedon May 30, 2025
I wonder how this kind of rule would alter context path matching?
Now: the path
/foo/..%2fbar/index.htmlwould match the context/fooand send the request there.With this new rule, the resulting path would be
/bar/index.html, matching the context/barinstead.joakime commentedon May 30, 2025
Also, we have seen custom rules in the wild to match against various known vulnerability scanning behaviors from rogue clients, and reject those request.
These kinds of rules have been verbose and tricky to write, but if they existed after this new proposed rule, many of the variants of rule matching would be much simpler to match against, probably even eliminating many variants of regex / patterns used.
gregw commentedon Jun 2, 2025
@joakime I'm wondering if just a rule would be good enough. A rule would just correct forever. If it was put in a handler, then it could have more nuanced handling. Ideally you'd want to have a mechanism to wean bad clients off those bad URI's. So at some stage it needs to reject them with a 400 bad request message, perhaps with some instructions on how to request and exemption that can be put into their session and/or user data.
Issue #13190 - Add setDecoding and setCanonicalizing to CompactPathRule
Issue #13190 - Add listener
joakime commentedon Jun 4, 2025
Decided to go a different route in PR
Added few features to
CompactPathRuleinstead.setDecoding(boolean)- false by default, true to run decodePathsetCanonicalizing(boolean)- false by default, true to run canonicalizePathaddListener(Listener)- optional listener to get notified when a compactPath rule changed the path.This is where a user can add their own audit logging to record where bad clients are coming from, and approach those bad clients to get them to change their behaviors in the future.
[-]Introduce `DecodeAmbiguousPathCharactersRule`[/-][+]Introduce ability to decode and/or canonicalize URIs in a RewriteRule[/+]Issue #13190 - Add CompactPathRule support for decoding and canonical…