Skip to content

fix(iis): strip IPv6 zone/scope id from client IP string - #3631

Open
A13501350 wants to merge 1 commit into
owasp-modsecurity:v2/masterfrom
A13501350:fix/iis-ipv6-scope-id
Open

A13501350 wants to merge 1 commit into
owasp-modsecurity:v2/masterfrom
A13501350:fix/iis-ipv6-scope-id

Conversation

@A13501350

Copy link
Copy Markdown

Summary

Windows GetNameInfo() appends the zone/scope identifier (e.g. "%6") to
link-local IPv6 addresses (fe80::/10) in their string form, because
sin6_scope_id is the interface index for link-local addresses.

ModSecurity's IP-match parser rejects addresses containing a zone suffix,
causing "IPmatch: bad IPv6 specification" and rule processing failures
(e.g. id=905110) for clients connecting from link-local IPv6.

Root cause

iis/mymodule.cpp — GetIpAddr() builds the client IP string consumed as
REMOTE_ADDR / client_ip. The "%" suffix makes the address
unparseable by ModSecurity's IP matcher.

Fix

Strip the "%" suffix from the textual IP in GetIpAddr() for
AF_INET6. The binary address (sin6_addr) carried by CopySockAddr() is
unaffected, and the zone id is irrelevant for IP matching. Added
#include <string.h> for strchr().

Fixes #3630

Windows GetNameInfo() appends the zone/scope identifier (e.g. "%6")
to link-local IPv6 addresses (fe80::/10) in their string form, because
sin6_scope_id is the interface index for link-local addresses (per
Microsoft docs: "fe80::208:74ff:feda:625c%5").

ModSecurity's IP-match parser rejects addresses containing a zone
suffix, causing "IPmatch: bad IPv6 specification" and rule processing
failures (e.g. id=905110) for clients connecting from link-local IPv6.

Strip the "%<zone>" suffix from the textual IP passed to ModSecurity in
GetIpAddr(). The binary address (sin6_addr) used for the actual socket
is unaffected, and the zone id is irrelevant for IP matching.
@coderabbitai

coderabbitai Bot commented Sep 17, 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: 80798ace-3d63-4b90-bd23-2b985f558e84

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.

@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The reviewed change addresses the stated parsing issue without unresolved blocking concerns.

Pull request overview

Fixes IIS IPv6 link-local client IP parsing by removing Windows zone identifiers before ModSecurity matching.

Changes:

  • Adds string.h for strchr.
  • Strips %zone suffixes from IPv6 address strings.
File summaries
File Description
iis/mymodule.cpp Normalizes IPv6 client IP strings before ModSecurity processing.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@airween airween added Platform - IIS 2.x Related to ModSecurity version 2.x labels Sep 17, 2026
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 Platform - IIS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants