Skip to content

Fix wildcard header and parameter names in MustMatchRule - #927

Open
VolodymyrLinuxovich wants to merge 1 commit into
ESAPI:developfrom
VolodymyrLinuxovich:issue-458
Open

VolodymyrLinuxovich wants to merge 1 commit into
ESAPI:developfrom
VolodymyrLinuxovich:issue-458

Conversation

@VolodymyrLinuxovich

Copy link
Copy Markdown

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regex Syntax error on Line 106 of MustMatchRule.java

1 participant