Replies: 9 comments 4 replies
-
Okay - @xeno6696 - This looks like code you added as part of addressing GitHub issue #394; could you please take a look at it? Also, @krog78 - Did you have a specific test case in mind and what your expectations for your test case were so we could include it in a future JUnit test? Thanks. |
Beta Was this translation helpful? Give feedback.
-
There's not enough data here for me to offer a diagnosis. What's the input URL that's giving you trouble? @krog78 we have to start there or there's no conversation to be had. The method is designed to allow Mixed or Multiple encoding depending on what you have set in your ESAPI.properties file, I would check there first. As written the line to canonicalize is begins like this:
This iterates over the entire set, queries, if present, included, and they will get canonicalized on this line. Unless of course, you've configured allowMixed and allowMultiple contrary to your intentions. I DO see that I didn't mention in the documentation that those parameters come from ESAPI.properties and will update the docs accordingly. Further, all of the regression tests were updated in ESAPI to use getCanonicalizedURI, not saying that we couldn't have missed something, but having walked through the code here, I'm not seeing anything obviously wrong. As for the question:
Would have been nice to have you on the code review back when this was created, I DID NOT think deeply about each URL segment, so this is a bug. Part of what this method was designed to perform was to avoid the general bad practice of using regex to validate URLs when URLs have their own BNF grammar. Validating against that segment breaks our intent, so this is definitely a bug. Separate from your original issue however, which we still have to determine. I'm currently running a regression having taken that piece out. Please get back to us with the input and usage, and properties file configurations so we can make a determination. |
Beta Was this translation helpful? Give feedback.
-
Forgot to answer the other half of this question. Yes, scheme/host are relevant. |
Beta Was this translation helpful? Give feedback.
-
Actually, the more I reflect on this, How are you getting a mixed/multiple encoding exception? The only OTHER way I can see it happening is if you’re applying the OLD canonicalize method to the output from |
Beta Was this translation helpful? Give feedback.
-
Did a deep dive with a test case, can confirm that URL query strings are indeed canonicalized twice, once on line 541 as demonstrated above, and again in the splitQuery method on lines 618-632. I would have expected the line on 541 to result in false positive on the URL query but after running several sets of new unit tests to try and tease out the indicated behavior, I'm not striking gold. I did however find a bug but we're failing secure. With the following input: we get an unexpected URL back, it's multiple encoding and I can validate that we do throw an exception properly, I haven't tested mixed encoding yet but I have noticed that I didn't have unit tests done to explicitly ensure we catch and throw those exceptions. So that's a good find. The query string that has the multiple encoding returns I'll leave this open until midweek barring an example parameter, but if that doesn't happen this is a "can't reproduce." |
Beta Was this translation helpful? Give feedback.
-
Scratch that, it's not a bug, though I still need those unit tests. getCanoncializedURI(URI) assumes that the programmer is knowledgeable enough with the programming idioms used in ESAPI to catch Mixed/Multi exceptions, which since they're runtime exceptions, could escape if you're not expecting them. It's the old design biting us in the ass. In hindsight, I should never have exposed that method, we should only have exposed the convenience methods on the Validator interface. |
Beta Was this translation helpful? Give feedback.
-
@xeno6696 - if you decide this is a bug or need to make a code or Javadoc
change, please turn this discussion into an issue. That will get it into
our next release notes. Thanks.
…-kevin
|
Beta Was this translation helpful? Give feedback.
-
Hi, We effectively have both parameters set to false:
The URL we are using is of kind
The warning is produced when seg = SCHEMSPECIFICPART and on seg = QUERY because of line (the full line is canonicalized).Note: the canonicalize parameters of the function are The first HTMLEntityCodec decodes the string as:
How should we validate such URLs (containaing HTML special chars) ? Thanks, |
Beta Was this translation helpful? Give feedback.
-
Going to close this discussion, please forward any future comments to #824 |
Beta Was this translation helpful? Give feedback.
-
Hi,
DefaultEncoder / getCanonicalizedURI returns mix encoding for HTML special characters in query string (and does not seem to canonicalize the parameter value despite the fact it is mentionned):
esapi-java-legacy/src/main/java/org/owasp/esapi/reference/DefaultEncoder.java
Line 573 in 2136292
And the canonicalize is applied to scheme, host, port and also UriSegment.SCHEMSPECIFICPART, is it really relevant?
Thanks,
Regards,
Sylvain
Beta Was this translation helpful? Give feedback.
All reactions