One of my REST APIs have a query parameter named "partners" which is an List of Integers, so you can specify multiple values in the URL. As a prevention for XSS attacks, I am stripping out malicious content in the input using ESAPI. Here is the problem:
I noticed that the ESAPI encoder cannonicalize method (which uses the default codecs: HTMLEntityCodec,PercentCodec,JavaScriptCodec), changes the query parameter values, because it thinks that &p or &pa is some kind of encoding. See examples below
Something like
http://localhost:8080/product?partner=1
Works as expected.
On the other hand something like
http://localhost:8080/product/?pidentity=1&pidentity=2
The input after canonicalizing becomes
`pidentity=1πdentity=2`
Which the framework has trouble parsing since it thinks this is only one query parameters with 2 splitters.
If the request url is like
http://localhost:8080/product?partner=1&partner=2
The input after canonicalizing becomes
partner=1∂rtner=2
And &pa is changed to '∂'.
As you can probably guess, I tried changing the name of the query param and it worked fine (probably because there was not any corresponding encoding). Has anyone seen that before, or can guide me what must be causing such behavior? This may sound like my inexperience, but in order to ensure prevention from XSS attacks, I am not sure if I should try to remove any codecs from the default encoder.