-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Audit log: Failed to lock global mutex: Permission denied #454
Comments
Original reporter: littleb |
littleb: I made an error and listed 2.5.6 as the mod_security version.The correct version is 2.6.3. |
bpinto: Hello Chris, Could you send the necessary configuration options to reproduce the issue ? Thanks |
tomdchi: I am having the same problem. This error happens when using ownCloud file sharing software from owncloud.org and using the sync client to sync files. It also triggers the CSF firewall to block the IP address. I have a similar setup that does not use mod_ruid2 and do not have this problem with the ownCloud software. The other difference on the second server is that it uses suphp as the Apache handler. |
tomdchi: modsec rules that are being used. |
arondeparon: I am having the exact same issue with a similar configuration. |
jazz: Debian 2.6.39 The same problem. |
eagle1: Same here with MPM-ITK on Debian, with Apache 2.2, PHP5.3 (dotdeb) anche mod_security2 from backports. |
hi, same here using nginx 1.4.2 with modsecurity-apache_2.7.5 - if I use Concurrent logging, it seems to work, however, then the nginx workers are being killed (there was a previous bug) Alex |
I'm getting this on Nginx 1.5 modsec 2.7.5 and owncloud. I don't believe the specific rule is relevant to the problem, but here you go : --aebe1c6a-A-- --aebe1c6a-F-- --aebe1c6a-E-- --aebe1c6a-H-- --aebe1c6a-Z-- Obviously owncloud falls foul of the CRS rules, but I'm intrigued by the mutex error as it may help me to identify why I don't have any persistency (IP, USER, presumably SESSION as well) under Nginx. Off to disable the offending rule (which will probably take me some hours!). Paul. |
same here - running mod_itk |
Still getting this error with serial logging. Is it safe to use serial logging at all? 2014/03/31 12:43:43 [notice] 12335#0: ModSecurity for nginx (STABLE)/2.7.7 (http://www.modsecurity.org/) configured. |
Same here using the mpm itk on CentOS 6 . mod_security-2.7.3-3.el6.x86_64 |
I viewed code and saw when I ran nginx under |
Sorry to bump this issue but its been almost a year. Does anyone know of a working fix for this ? |
I have the same exact issue using nginx 1.7.8 |
All, it's because your mutex (in this case semaphore) is created with another user than nginx is running. You can verify with:
Most simplest patch this would be:
Of couse this can be compiled with -DDEFAULT_USER and so on, but it would require to have libapr, libapache2-dev, etc. |
I've written a patch that solves it. It basically adds the username to the path where it creates the log files. It works and we use it in production, but to be merged upstream it will probably need a configurable setting. There is a pull request waiting to be merged for mod_ruid2 as that will not work out of the box either. |
Hmm I thought you have to have libapr or apache-dev to get this working with nginx. With those libs I can compile with DEFUSER and get no mutex lock errors? Sent from my iPhone
|
The patch by ju5t addresses the file permission issues, when the log and persistance directories are set up with mode 1777 (as happens to be the case on Unix for the default location of /tmp). Unfortunately, getting around the lock issues under mpm-itk requires more jiggery pokery, because evidently apr_global_mutex_create and ap_unixd_set_global_mutex_perms get called when Apache has changed uid to www-data, but references the mutex when running as the site's AssignUserID, thus causing the lock failures that starting this thread. |
Affects me as well, on an Nginx 1.6.2 on Ubuntu setup. |
I have the same exact issue using nginx 1.6.3. nginx 1.6.3 |
I think that Modsecurity module doesn't care the user of worker processes. You can solve this issue if you set user directive to root in nginx.conf. "user root;" but it's dangerous to vulnerability. |
You need to change how the audit logging works. See: https://atomicorp.com/forums/viewtopic.php?f=1&t=7964 as an example solution. |
@jowrjowr No that isn't a real fix. If you follow all the big hosting panel providers (like Cpanel) they are now all running their own patched versions of mod_security. That's the only way to work around this issue. As this issue has now been opened for years I don't think that the mod_security team really cares about this issue. |
True. Had to stop selling modsecurity to our clients. No way to get it working with nginx. They keep tellung me "just switch the inspection off". That is like wearing a condom over your head. Won't help and makes you sweat Sent from my iPhone
|
@jowrjowrWe have disabled modsec also - it does not seem to be compatable with modruid2 and anel. Both Cpanel and Spiderlabs clearly want this to work (especially a Cpanel) but this issue has not received serious attention. Perhaps its an edge case. Cpanel has an internal ticket but I think they need some expertise from Spiderlabs to actually resolve the issue. Hope SpiderLabs and Cpanel can get on the same page as this is hurting both their reputations. |
Hum? I'm not saying switch the inspection off, I'm just saying change how the logging works. That's working for me on one webserver. Though I did hit a 100% CPU bug, of course. I really want this to work. But its' being made as difficult as possible. |
@jowrjowr The problem with this approach is that changing it to serial decreases the functionality / performance of mod_security considerably. Also all audit consoles require logging to be set to concurrent. (mlogc requires concurrent logging). |
Alright, I can't argue with that. So, uh, does the Apache version have these problems? On Mon, Apr 27, 2015 at 12:51 PM, Gazoo [email protected] wrote:
|
@jowrjowr Yes the issue is present in both Apache and Nginx. |
What if the log messes were simply dumped to syslog() and we bypass the On Mon, Apr 27, 2015 at 12:53 PM, eric gisse [email protected] wrote:
|
The power of concurrent logging is that it stores the full HTTP transaction in dedicated files allowing you to do proper auditing / debugging. That's not something you can just dump to syslog. |
Note: Please see the following related comments- |
Sure it can, if you throw enough log messages at it. modsec assigns each transaction a unique ID. Throw the HTTP data into This solves the log concurrency issue, by putting it elsewhere. Which I Is there an internal nginx log output functionality modsec could use On Mon, Apr 27, 2015 at 1:00 PM, Gazoo [email protected] wrote:
|
Modsecurity works on Apache, even with mpm-itk (and I would presume, mod_ruid2), provided the vhost it runs in does not use AssignUserID (nor RUidGid, for ruid2). I'm using this to run modsecurity in a vhost that just proxies requests to the vhosts that run the actual websites. Basically, modsecurity runs as a completely separate frontend WAF in this scenario. This works as long as all sites behind the WAF can live with a common ruleset. I'm happy with this setup, YMMV. It would be nice if modsecurity would fully support mpm-itk, but it seems to be a hard nut to crack. Maybe something for Google's summer of code. |
Writing the log entries to syslog won't solve the issue. There's another file that is used to track IP addresses and that has the same problem. I'm using my own patched version to get around that for now which is mentioned in #712. As it's a pretty rough and probably dirty patch (I'm not a developer let alone one that can write c very well) I haven't sent in a pull request for it. Mod_ruid2 has another issue where it doesn't initiate the ap_hook_post_read_request call at the right moment, so even when Mod Security is patched for this issue it will fail because some files are still created with the wrong owner. I've sent a pull request in that particular case as it was an easy fix, but it hasn't been accepted for months now. |
To solve the problem Audit log: Failed to lock global mutex: Permission denied find the configuration file which loads finally in mod security (example: /usr/local/apache/conf/modsec2.cpanel.conf) Add these line to the end of file: SecAuditLogDirMode 1733 Check the directory of /usr/local/apache/logs/modsec_audit for proper permissions of : 1733 This solved my problem |
parsmizban's solution worked for me, but I added the text to modsec2.user.conf, under the reasoning that modsec2.cpanel.conf will get overwritten by cpanel. Thanks! |
Sorry to stir up an old bug. Does this error also block the request? or is it just an issue of filling up the logs with errors? Thank you. |
I am an EasyApache developer for cPanel. If you're using a cPanel system with EasyApache, you do not need to update modsec2.cpanel.conf, nor do you need to update modsec2.user.conf with any directives to enable Concurrent logging. EasyApache 3 automatically configure Apache within modsec2.conf with the proper directives. Here's an excerpt of what you should see. EasyApache 3 (/usr/local/apache/conf/modsec2.conf)
EasyApache 4 (/etc/apache2/conf.d/modsec2.conf)
IMPORTANT NOTES
|
Hi guys, i'm still having problems with this in version 2.9.3 (apache with ITK): I tried to recompile modsecurity with --disable-collection-global-lock but errors are still logged. |
There is also an example of solving the global mutex problem with the Apache2 MPM ITK module. This project (Apache mod security log parser) demonstrates an approach. |
On top of PR #3188, I wonder if it won't be better, at least for the Apache version, to use Apache mutex mechnaism (ap_proc_mutex_create or ap_global_mutex_create?) and use another type of mutex (in the config), like "pthread". Just an idea, I don't know the internals of these but it may worth to dig into this. |
@marcstern - just my 2 cents: even though that PR is merged but unreleased, so nobody has used yet that, this is why I bring their attention. |
Why is this closed? |
I'm afraid nobody knows the reason... It had been closed on 23rd of Sep, 2018 |
Does this still occurs with 2.9.8? |
I encountered this issue in the production environment: In the solution, I used global settings, and some difficulties could have been avoided by using subdirectories in the virtual host for: SecTmpDir, SecDataDir, SecAuditLogStorageDir. In modsec_audit.log, I regularly encountered messages: My problem is solved, and I revived the issue because I found it in search and used it as a reference in solving my task. |
@commeta: My problem is solved |
Apache/2.4.6 mpm-itk/2.4.7-04 |
MODSEC-306: When running both Mod Security and Mod Ruid 2, my Mod Security audit log fills up with the following error 'Audit log: Failed to lock global mutex: Permission denied'.
The text was updated successfully, but these errors were encountered: