-
-
Notifications
You must be signed in to change notification settings - Fork 401
Plugins may need to be able to hook into any of the rules files #3154
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
Comments
Thanks Max. Agreed we need to review. |
901160 is only initializing allowed_methods if the variable is not yet existing. So if the plugin defines the variable in the plugin-config.conf, the problem is solved. I agree there is a chance where you want to extend allowed_methods without looking at the default setting of allowed_methods, but I do not th 8000 ink we have to accommodate for this situation. Why not: Because if a user want to modify allowed_methods without looking at the default value, he / she runs the risk of adding a method that is already defined in allowed_methods. So technically you would have to inspect allowed_methods and if the method in question is not yet part of the variable then you add it. But I think this is all overkill and I would take a pragmatic approach. Doubling down on this: @theseion mentioned "upload a file in a specific context". That implies a given URL. And if you know the URL and that it's about an operation like file upload, there is no point in extending the existing allowed_methods variable. You simply set it to method you are expecting. |
We also still have a really nasty plugin architectural question open here which we need to address eventually: May be related (I need to fully re-read both issues when I have the time…) |
This is the exact same problem. It is an edge case and even if I may be downplaying it, I would rather not change the plugin architecture again before the release. I would rather roll it out, get some experience and then maybe adjust things for 4.1. We can to bring our own recommended rules for 4.1 as well, so there is a chance we will look into variable initialization for 4.1 anyways and address this for good. |
For
But now imagine the same scenario with a variable like |
Does not your
I do not see us finding the elegant solution right now. |
After re-examining this topic (also re-reading the other identical open issue), this sounds like the best plan so far. Here's a radical thought: Why do we have redundant pairs of rules, for example one rule that does:
and then another, different rule that does:
If we're planning to make significant changes to As long as we clearly state what the default values are - that's a good thing about having a separate Or maybe there's a very good reason for having those redundant rule pairs that I'm forgetting 😅 |
Fine by me. As the discussion is stalling a bit (for the second time) I seems to be more important to have a working solution, rather than the perfect one, for now. Let's quickly talk about it in the chat tonight. |
As decided in the the chat, we solve this for now by duplicating initialization rules in plugins to set defaults, if necessary. |
Initiated by this discussion: coreruleset/nextcloud-rule-exclusions-plugin#12.
Scenario
We want to modify
allowed_methods
(default:GET HEAD POST OPTIONS
) in a plugin to include another method conditionally, e.g., to upload a file in a specific context. Modifyingallowed_methods
is great, because there's already a rule that takes care of blocking and anomaly scoring for us.Problem
allowed_methods
is initialised inREQUEST-901-INITIALIZATION.conf
and checked for compliance inREQUEST-911-METHOD-ENFORCEMENT.conf
. The plugin system can currently run rules either before all CRS rules, or after all CRS rules. Neither of those two options makes it possible to modifyallowed_methods
with the expected outcome.We could work around this limitation by copying the rule from
REQUEST-911-METHOD-ENFORCEMENT.conf
to the plugin and then running the modification rule and the checking rule after the CRS rules. I don't believe that this is ideal though. We should try to prevent duplication of rules by plugins.Instead, I think we need to (again) discuss the option to run plugin rules after
REQUEST-901-INITIALIZATION.conf
. Maybe we could even add "before" and "after" hooks to all of the CRS rules files (probably not necessary).I don't think ModSecurity allows including other files from
.conf
files, which would make it easy to solve this problem.The text was updated successfully, but these errors were encountered: