Skip to content

Allow processing of ErrorDocument#3514

Open
JonathanBerrew wants to merge 1 commit intoowasp-modsecurity:v2/masterfrom
JonathanBerrew:allow-processing-of-errordocument
Open

Allow processing of ErrorDocument#3514
JonathanBerrew wants to merge 1 commit intoowasp-modsecurity:v2/masterfrom
JonathanBerrew:allow-processing-of-errordocument

Conversation

@JonathanBerrew
Copy link
Copy Markdown

This is a Marc Stern modification, I don't have much more insight on the code he made. To be reviewed with caution and check if this is still relevant

@sonarqubecloud
Copy link
Copy Markdown

@airween airween requested a review from Copilot April 22, 2026 15:36
@airween airween added the 2.x Related to ModSecurity version 2.x label Apr 22, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates ModSecurity’s Apache2 utility helper for sending error buckets, apparently aiming to influence how Apache processes custom ErrorDocument responses during interception.

Changes:

  • Modifies send_error_bucket() to force the request status to 200 before emitting an Apache error bucket.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apache2/apache2_util.c
Comment on lines 33 to +35
/* Set the status line explicitly for the error document */
f->r->status_line = ap_get_status_line(status);
f->r->status = 200;
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

Setting f->r->status = 200 while also setting status_line to an error status and sending an error bucket makes the request status inconsistent with the intended error response. In particular, protocols like HTTP/2 rely on r->status (not status_line) to populate :status, which can cause intercepted/blocked responses to be sent as 200 OK. Align r->status with the status argument (or avoid overriding it here and let the error bucket handling set it), so the final response code matches the interception status and ErrorDocument processing works correctly.

Suggested change
/* Set the status line explicitly for the error document */
f->r->status_line = ap_get_status_line(status);
f->r->status = 200;
/* Set the status explicitly for the error document */
f->r->status_line = ap_get_status_line(status);
f->r->status = status;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.x Related to ModSecurity version 2.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants