Repository navigation
Conversation
SecAuditLog, SecAuditLog2 and SecGuardianLog open their "|program" pipes with ap_open_piped_log() while the configuration is read. httpd closes the read end of its own piped logs in each child (ap_logs_child_init), but that list is rebuilt after the configuration pool is cleared, so the read ends opened by ModSecurity stay open in every worker. A worker holding the read end of a pipe never gets EPIPE when the logger process dies, and after a graceful restart it blocks in write() for ever, which is the hang reported in owasp-modsecurity#2822. The read ends are now remembered when the pipes are opened and closed from the child_init hook, mirroring what httpd does for its own logs. Fixes owasp-modsecurity#2822 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0181jBv5JdNQviwDzfnkf1Gy
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What
SecAuditLog,SecAuditLog2andSecGuardianLogopen their|programpipes withap_open_piped_log()while the configuration is read. The read ends of those pipes are now remembered (apache2/apache2_config.c) and closed from thechild_inithook (apache2/mod_security2.c), which is what httpd does for its own piped logs inap_logs_child_init().Why
httpd keeps a list of piped-log read ends to close in every child, but that list is reset by a cleanup on the
plogpool, which runs after the configuration (and therefore after our directives) has been read. So every worker inherits the read end of ModSecurity's pipes. A worker that holds the read end of a pipe never getsEPIPEwhen the logger process is gone, and once the pipe buffer is full it blocks inwrite()for ever; that is the hang during graceful restart reported in #2822 (backtrace insec_auditlog_write).Tests
Verified in a Debian bookworm container (apache2 2.4.62, prefork) with
SecAuditLog "|/usr/bin/rotatelogs ...", listing which processes hold the pipe rotatelogs reads from:Requests,
kill -9of rotatelogs and a graceful restart behave the same on both (the hang itself needs a full pipe buffer in an old-generation worker, which this short test does not drive). No regression test: the harness has no way to inspect worker file descriptors.References
Fixes #2822
🤖 Generated with Claude Code