Skip to content

iis: drop chunked Transfer-Encoding when Content-Length is set - #3618

Open
A13501350 wants to merge 1 commit into
owasp-modsecurity:v2/masterfrom
A13501350:iis-fix-chunked-te
Open

iis: drop chunked Transfer-Encoding when Content-Length is set#3618
A13501350 wants to merge 1 commit into
owasp-modsecurity:v2/masterfrom
A13501350:iis-fix-chunked-te

Conversation

@A13501350

Copy link
Copy Markdown

Summary

In iis/mymodule.cpp, WriteBodyCallback copies the inbound request headers verbatim (including Transfer-Encoding) and then sets Content-Length on the request. The result can be a request that carries both Transfer-Encoding: chunked and Content-Length, which is malformed and is rejected by some backends / causes ambiguous framing.

Change

Right before setting Content-Length, if the request's Transfer-Encoding header is chunked, delete it via pHttpRequest->DeleteHeader(...). Only one framing header is left on the forwarded request.

Provenance

Adapted from microsoft/ModSecurity branch waf_iis. Verified still missing on current v2/master tip (0875b19, v2.9.14).

@coderabbitai

coderabbitai Bot commented Aug 22, 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: Pro Plus

Run ID: c83f2bfc-feac-4380-abac-612b9571cd0b

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

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.

WriteBodyCallback copies the request Transfer-Encoding header verbatim and
then sets Content-Length, so the forwarded request could contain both
Transfer-Encoding: chunked and Content-Length, which is malformed and
rejected by some backends.

Delete the Transfer-Encoding header when it is chunked right before setting
Content-Length, so only one framing header remains.

Adapted from microsoft/ModSecurity waf_iis.
@sonarqubecloud

Copy link
Copy Markdown

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