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

Block $bad_uri_words prototype #365

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

duzun
Copy link

@duzun duzun commented Mar 12, 2020

I have created a new rule to block some injection attempts by testing the incoming $request_uri.

I don't know how to correctly add these changes to the repo :(

Maybe it is worth adding a similar rule based on $uri, which is a normalized version of $request_uri.

@auto-comment
Copy link

auto-comment bot commented Mar 12, 2020

Thank your for raising your pull request.
Please make sure you have followed our contributing guidelines. We will review it as soon as possible

@mitchellkrogza
Copy link
Owner

Thanks for your PR @duzun introducing a new include and mapping can and will break many installations out there who update and have a missing include file. Multiple include files were added from the beginning to allow such customization. Your best approach this to your /bots.d/bad-referrer-words.conf include file as follows.

"~*(?:\b)phpunit(?:\b)"    1;
"~*(?:\b)eval-stdin(?:\b)" 1;

This will work instead of having a complex regex.

@duzun
Copy link
Author

duzun commented Mar 13, 2020

I get your point.

But with the current configuration, there is no way to catch the spam words in the $request_uri, and the $http_referer is not enough.

Maybe it makes sense to add the new rule using the existing files, like bots.d/bad-referrer-words.conf?
Users who do not update their bots.d/blockbots.conf would not use the new rule, but it would not brack either.

@mitchellkrogza
Copy link
Owner

ah ok I get you, I'll have to think about how we could do this without breaking anything. Using the existing include files could work.

@@ -0,0 +1,17 @@
# EDIT THIS FILE AS YOU LIKE TO ADD OR REMOVE ANY BAD WORDS YOU WANT TO SCAN FOR ###
Copy link
Owner

Choose a reason for hiding this comment

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

Let's move these rules to bad-referrer-words.conf

@@ -75,6 +75,14 @@ if ($bad_referer) {
return 444;
}

# ---------------------------------
Copy link
Owner

Choose a reason for hiding this comment

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

This looks fine

@@ -18123,6 +18123,22 @@ geo $ratelimited {
# END SECTION 4 - ACTIVATE BLOCKER FUNCTIONS
# ==========================================


Copy link
Owner

Choose a reason for hiding this comment

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

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.

None yet

2 participants