New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JS: Add 'case sensitive middleware' query #9718
base: main
Are you sure you want to change the base?
Conversation
| <overview> | ||
| <p> | ||
| Using a case-sensitive regular expression path in a middleware route enables an attacker to bypass that middleware | ||
| when accessing an endpoint with a case-insensitive path. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to explain that explicit string routes typically are treated case-insensitively.
|
|
||
| <recommendation> | ||
| <p> | ||
| When using a regular expression as a middlware path, make sure the regular expression is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| When using a regular expression as a middlware path, make sure the regular expression is | |
| When using a regular expression as a middleware path, make sure the regular expression is |
| * Converts `s` to upper case, or to lower-case if it was already upper case. | ||
| */ | ||
| bindingset[s] | ||
| string invertCase(string s) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In isolation, I find the naming confusing here. If s is mixed case, it will be upper-cased, that does not sound like an inversion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to toOtherCase
| } | ||
|
|
||
| /** | ||
| * Holds if `term` distinguishes between upper and lower case letters, assuming the `i` flag is not present. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that this predicate suits the query: it identifies the typical regexp routes such as /admin\/.*/.
The predicate will however also hold (wrongly) for cases such as /a|A/ or /[abcA-C]/
Could the docstring/predicate name be something like isCaseSensitiveRouteRegExp?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to isLikelyCaseSensitiveRegExp
LGTM. Thanks for making this query a reality.
We are ready for the docs review.
Adds a query for detecting middlewares that can be bypassed due to having a case-sensitive regular expression as its path.
Evaluations have been split into a few parts: