Repository navigation
Fix wildcard header and parameter names in MustMatchRule - #927
Open
VolodymyrLinuxovich wants to merge 1 commit into
Open
VolodymyrLinuxovich wants to merge 1 commit into
VolodymyrLinuxovich wants to merge 1 commit into
Conversation
String.replaceAll("*", ".*") throws PatternSyntaxException, so every
must-match rule with a wildcard header or parameter name failed. Escape the
star the same way the session attribute branch already does.
The request parameter branch also never returned DoNothingAction when the
check passed, so it always fell through to the fail closed default. Return
DoNothingAction there like the header branch does.
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.
Closes #458.
MustMatchRule called
target.replaceAll("*", ".*")for wildcard header and parameter names. A bare star is not a valid regex, so every such rule threw PatternSyntaxException. The session attribute branch already escapes it as"\\*". This PR does the same in the other two places.While testing I found the request parameter branch never returns DoNothingAction when the check passes. It falls through to the fail closed default at the bottom, so a matching parameter was still blocked. The header branch returns DoNothingAction in both cases. The parameter branch now does the same.
I added MustMatchRuleTest with six cases for wildcard headers, wildcard parameters and plain parameters. Five of them fail on develop. All 74 tests under org.owasp.esapi.waf pass with the change.
One more thing I noticed but left alone. RuleUtil.testValue for the contains operator checks
test.contains(s), so it asks whether the rule value contains the input. The comment in must-match-policy.xml reads the other way around. I can open a separate issue for that if it is useful.