Skip to content

IIS: propagate Location header on redirect interventions - #3689

Open
A13501350 wants to merge 1 commit into
owasp-modsecurity:v2/masterfrom
A13501350:fix-729-iis-redirect-request-phase
Open

A13501350 wants to merge 1 commit into
owasp-modsecurity:v2/masterfrom
A13501350:fix-729-iis-redirect-request-phase

Conversation

@A13501350

@A13501350 A13501350 commented Oct 14, 2026 •

Copy link
Copy Markdown

Summary

When a rule with a redirect action matches during the request phases, the core engine stores the target URI in the Location header of the fake request_rec's headers_out table and perform_interception() returns the
redirect status. The IIS module only forwarded the status code to the IIS response, so clients received a 301/302 without a Location header and the redirect never happened.

This fix reads the Location header from headers_out and sets it on the IIS response object when a request-phase intervention occurs (OnBeginRequest).

Fixes #729

Scope note

Response-phase (OnSendResponse) redirect handling requires further work on the IIS engine pipeline and is left for a follow-up issue.

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3283adbd-a8e1-4f58-a2c4-2ea6762ee9ad

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread iis/mymodule.cpp Dismissed
When a rule with a redirect action matches during the request phases,
the core engine stores the target URI in the "Location" header of the
fake request_rec headers_out table and perform_interception() returns
the redirect status. The IIS module only forwarded the status code to
the IIS response, so clients received a 301/302 without a Location
header and the redirect never happened.

Read the Location header from headers_out and set it on the IIS
response object when a request-phase intervention occurs.

Fixes owasp-modsecurity#729

The response-phase (OnSendResponse) path is handled separately, since
response phases currently never run on this connector.
@A13501350
A13501350 force-pushed the fix-729-iis-redirect-request-phase branch from b413e8b to b9a1758 Compare October 14, 2026 15:35
@sonarqubecloud

sonarqubecloud Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed

Issues
0 New issues
2 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@airween airween added the 2.x Related to ModSecurity version 2.x label Oct 15, 2026
@airween

airween commented Oct 15, 2026

Copy link
Copy Markdown
Member

Hi @A13501350,

thanks for this patch - could you add a new test case to the existing regression tests collection? Thanks!

This branch has not been deployed

No deployments
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