fix: Changed regex (920470) to match multiple whitespaces after Content-Type
parameters to avoid false-positives
#3818
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.
Description
This pull request addresses a false positive related to the
Content-Type
header being incorrectly flagged by rule ID 920470. The issue arises due to overly restrictive whitespace handling in the regex validation. The original regex allowed only an optional whitespace between parameters, which blocked valid headers containing additional whitespaces, even though these are permitted according to RFC standards.Problem
The original regex for rule ID 920470 did not account for multiple or flexible whitespaces between header parameters. This caused valid
Content-Type
headers, compliant with RFC 2045 and RFC 7231, to be blocked unnecessarily.Original regex
Updated regex
Changes
\s?;\s?
has been updated to\s?;\s*
to allow for flexible whitespace usage, in accordance with RFC 2045 and RFC 7231, which permit multiple whitespaces between parameters.Example
The blocked request contained the following Content-Type header:
This valid header was blocked because of extra spaces around the parameters, which are permitted under RFC specifications.
Impact
This update will prevent unnecessary blocking of valid HTTP requests while still maintaining the security provided by the rule.
Attachments
Original regex
Updated regex