Skip to content

fix: record real response status in IIS audit log F part - #2

Closed
A13501350 wants to merge 2 commits into
v2/masterfrom
pr/iis-audit-log-fpart-status
Closed

fix: record real response status in IIS audit log F part#2
A13501350 wants to merge 2 commits into
v2/masterfrom
pr/iis-audit-log-fpart-status

Conversation

@A13501350

Copy link
Copy Markdown
Owner

Fixes the audit log F-part status for the IIS connector.

Problem

The IIS connector never copies the HTTP response status into the
Apache request_rec used by the core engine. r->status stays 0, so
every audit log entry records 500 Internal Server Error
(ap_get_status_line(0)) in the F part, even for perfectly normal
200 responses.

Changes

  1. iis/mymodule.cpp (OnSendResponse): copy the real HTTP response
    status and reason phrase from the IIS HTTP_RESPONSE into r->status
    and r->status_line before the audit log runs.

  2. apache2/mod_security2.c (hook_log_transaction, guarded by
    #if defined(VERSION_IIS)): a transaction superseded by an IIS
    internal redirect (e.g. //iisstart.htm) never reaches
    OnSendResponse, so its r->status stays 0. Skip audit logging for
    such transactions unless the request was actually intercepted, instead
    of recording a bogus 500.

The IIS connector change is in the C++ module (IIS-specific). The
mod_security2.c change is guarded so it only affects IIS builds; Apache
behavior is unchanged.

Verification

IIS test pipeline runs the CRS regression smoke suite (913/920/930/941);
audit log shows real 200 status F-parts and zero bogus 500s.

The IIS connector never copied the HTTP response status into the
request_rec, so r->status stayed 0 and the audit log rendered the F part
as a bogus 'HTTP/1.1 500 Internal Server Error' (ap_get_status_line(0))
for every transaction.

Set r->status and r->status_line from the raw HTTP_RESPONSE in
OnSendResponse so the logging hook and relevant-status checks use the
real response code.
The IIS connector never copies the response status into the request_rec;
r->status is only set in OnSendResponse. A request superseded by an
internal redirect (e.g. the IIS default document rewrite of "/" to
"/iisstart.htm") never reaches OnSendResponse, so its r->status stays 0
and the audit log F part would record a bogus HTTP/1.1 500 Internal
Server Error (ap_get_status_line(0)).

Skip audit logging for such transactions unless they were actually
intercepted. A blocked request always reaches OnSendResponse with
r->status set (403), so it is unaffected.
@A13501350

Copy link
Copy Markdown
Owner Author

Closing: this PR was opened against the fork by mistake; the change targets upstream owasp-modsecurity/ModSecurity.

@A13501350 A13501350 closed this Aug 15, 2026
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.

1 participant