Skip to content
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

fix(942160): check REQUEST_FILENAME #3782

Merged
merged 12 commits into from
Aug 23, 2024
Merged

fix(942160): check REQUEST_FILENAME #3782

merged 12 commits into from
Aug 23, 2024

Conversation

mat1010
Copy link
Contributor

@mat1010 mat1010 commented Jul 26, 2024

This change addresses #3779

@mat1010 mat1010 changed the title Check REQUEST_FILENAME in 942160 fix(942160): check REQUEST_FILENAME Jul 26, 2024
theseion
theseion previously approved these changes Aug 1, 2024
Copy link
Contributor

@theseion theseion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I'd like to get a second opinion before I merge though.

@dune73
Copy link
Member

dune73 commented Aug 1, 2024

It's a nice bypass and a decent fix. Thanks @mat1010.

I wonder whether we still want to do REQUEST_BASENAME since we now cover REQUEST_FILENAME? It's redundant in most of the cases. But maybe REQUEST_FILENAME allows for a different type of bypass ...

@azurit
Copy link
Member

azurit commented Aug 1, 2024

While i was reviewing, before reading @dune73's comment, i come to the same conclusion - REQUEST_BASENAME is not needed.

@mat1010
Copy link
Contributor Author

mat1010 commented Aug 1, 2024

You are right. REQUEST_BASENAME is redundant. I removed it in f563dca.

But maybe REQUEST_FILENAME allows for a different type of bypass ...

Not sure if it allows some kind of bypass that wouldn't have worked before. In worst case it could catch more requests as the initial rule since it is now checking the full URI instead of just the name of the script.

While thinking about bypassing this rule I came to an additional easy bypass we have to consider.

Using comments like sleep(/*comment*/5) or pg_sleep(/*comment*/5)- this syntax is not blocked, but would work on a mysql and posgresql server. For benchmark this wont work since the regex is just matching for everything before and after the ,

mysql> SELECT sleep(/*comment*/5);
+-----------+
| sleep( 5) |
+-----------+
|         0 |
+-----------+
1 row in set (5.01 sec)
postgres=# select pg_sleep(/*comment*/5);
 pg_sleep
----------

(1 row)

I will also work on a fix to specifically address comments in the sleep command. Not sure if something like this would be to broad: (?i:sleep\(.*\d+.*\)|benchmark\(.*?\,.*?\))

@theseion
Copy link
Contributor

theseion commented Aug 2, 2024

Try using removeCommentsChar or replaceComments before making the regular expression unnecessarily complex.

mat1010 and others added 9 commits August 18, 2024 01:23
…et#3787)

* perf: remove unnecessary chain rule and capture for 921180

* fix: 921180 not logging ``logdata`` correctly
…ruleset#3788)

* Check that all rules have the correct CRS tag and version

* Change regexes to raw string; added 'git fetch --tags' before version determined

* Print commands' outputs to debug script

* Remove unnecessary subprocess commands

* Fetch tags before check

* Run git describe cmd

* chore: fetch enough commits for `git describe` to discover tags

* Update util/crs-rules-check/rules-check.py

Co-authored-by: Max Leske <[email protected]>

* Update util/crs-rules-check/rules-check.py

Co-authored-by: Max Leske <[email protected]>

* Update util/crs-rules-check/rules-check.py

Co-authored-by: Max Leske <[email protected]>

* Update util/crs-rules-check/rules-check.py

Co-authored-by: Max Leske <[email protected]>

* Update util/crs-rules-check/rules-check.py

Co-authored-by: Max Leske <[email protected]>

* Change message type format

Co-authored-by: Max Leske <[email protected]>

* Change message type format

Co-authored-by: Max Leske <[email protected]>

* Use `str` to convert string value

Co-authored-by: Max Leske <[email protected]>

* Change variable type format

Co-authored-by: Max Leske <[email protected]>

* Add triple " to formatted string

* Change message type format

Co-authored-by: Max Leske <[email protected]>

* Remove unnecessary escapes

Co-authored-by: Max Leske <[email protected]>

* Change regex format to raw string

Co-authored-by: Max Leske <[email protected]>

* Change regex format to raw string

Co-authored-by: Max Leske <[email protected]>

* Remove unnecessary escapes

Co-authored-by: Max Leske <[email protected]>

---------

Co-authored-by: Max Leske <[email protected]>
* fix: add pem to restricted file extensions

* chore: add esad cetiner to authors in 920440 tests
* fix no_expect_ids typo

* fix expect_ids not nested under "log"
@mat1010
Copy link
Contributor Author

mat1010 commented Aug 17, 2024

Sorry for the long delay. I added the the comment handling and a test for it.

@fzipi fzipi requested a review from theseion August 20, 2024 12:18
@fzipi
Copy link
Member

fzipi commented Aug 20, 2024

@theseion @dune73 @azurit Can we merge this one?

@fzipi fzipi added this pull request to the merge queue Aug 23, 2024
Merged via the queue into coreruleset:main with commit a29f883 Aug 23, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants