Repository navigation
WW-5829 fix(interceptor): apply parameter value filters to every value of a multi-valued parameter - #2087
Open
g0w6y wants to merge 1 commit into
Open
WW-5829 fix(interceptor): apply parameter value filters to every value of a multi-valued parameter#2087g0w6y wants to merge 1 commit into
g0w6y wants to merge 1 commit into
Conversation
…e of a multi-valued parameter ParametersInterceptor passed only Parameter.getValue() (the first value) to ParameterValueAware and the excluded/accepted value patterns, so a request such as a=ok&a=evil was accepted although "evil" would have been rejected. Check each value. Unlike JSONInterceptor, which drops only the bad list element, a single rejected value rejects the whole parameter (as a rejected first value already did). Single-valued and empty parameters behave as before.
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 WW-5829
What & why
ParametersInterceptorhands onlyParameter.getValue()(the first value) toParameterValueAware.acceptableParameterValueand to the excluded/accepted value patterns, but then sets the wholeString[]on the action. So?tags=ok&tags=evilpasses a filter that rejectsevil, while?tags=eviland?tags=evil&tags=okare rejected.JSONInterceptoralready checks every element of a JSON array (WW-4858). This checks every value of a repeated form parameter too, with one difference: JSONInterceptor drops only the bad list element, while here one rejected value rejects the whole parameter.Change
isAcceptableParameterValueandisAcceptableParameterValueAwarenow check every value of a multi-valued parameter (small private helpervaluesToCheck). One rejected value rejects the whole parameter, which is what already happens when the first value is rejected. Single-valued and empty parameters go through the same calls with the same argument as before.How verified
Three tests added to
ParametersInterceptorTest(excluded patterns, accepted patterns,ParameterValueAware), each covering single value, all values good, first value bad, second value bad.Tests run: 48, Failures: 3(all three new tests:secondBadreached the stack).ParametersInterceptorTest(48),ParameterAuthorizerTest(42) andStrutsParameterAnnotationTest(33) pass.ParameterValueAwarethat rejectsevil:?tags=ok&tags=evilwas accepted before (the action received[ok, evil]) and is rejected with the change;?tags=ok&tags=finestill binds.Not changed
Risk
Behaviour changes only for actions that configure value patterns or implement
ParameterValueAwareand receive repeated parameters where a later value is rejected; those requests were previously (wrongly) accepted. Cost is one extra pattern match per additional value.