Skip to content

XS✔ ◾ Secure IP Address Filtering - #883

Open
Muiris Woulfe (muiriswoulfe) wants to merge 5 commits into
mainfrom
fix/ip-address-filter-spoofing
Open

XS✔ ◾ Secure IP Address Filtering#883
Muiris Woulfe (muiriswoulfe) wants to merge 5 commits into
mainfrom
fix/ip-address-filter-spoofing

Conversation

@muiriswoulfe

Copy link
Copy Markdown
Member

Purpose

Prevent clients from bypassing IP-based feature controls through untrusted forwarding data.

Impact

IP-gated features now rely on trusted connection information. Updated guidance and regression coverage reduce the risk of reintroducing the bypass.

Copilot AI lite review requested due to automatic review settings August 25, 2026 14:27
@muiriswoulfe
Muiris Woulfe (muiriswoulfe) requested a review from a team as a code owner August 25, 2026 14:27
@muiriswoulfe Muiris Woulfe (muiriswoulfe) added the bug Something isn't working label Aug 25, 2026
@muiriswoulfe

Copy link
Copy Markdown
Member Author

Replaces #881 so the head branch is hosted directly in microsoft/Omex. The original pull request retains the earlier review timeline.

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.

Pull request overview

This pull request hardens the FeatureManagement IP address filter to prevent bypass via spoofed forwarding headers by relying exclusively on trusted connection metadata (HttpContext.Connection.RemoteIpAddress). It aligns implementation, documentation, and regression tests to ensure the filter’s decisions are based on server-established client IP information (optionally populated via Forwarded Headers Middleware).

Changes:

  • Updated IPAddressFilter to evaluate only HttpContext.Connection.RemoteIpAddress (no X-Forwarded-For, no “local request” bypass).
  • Removed forwarded-IP parsing/local-detection helpers and their unit tests, and added/updated filter unit tests to assert forwarded headers are ignored.
  • Added explicit guidance to FeatureManagement documentation and repo Copilot instructions on configuring Forwarded Headers Middleware safely.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/FeatureManagement.UnitTests/Filters/IPAddressFilterTests.cs Updates tests to set RemoteIpAddress and verify X-Forwarded-For is ignored for filter decisions.
tests/FeatureManagement.UnitTests/Extensions/HttpContextExtensionsTests.cs Removes tests for extension methods that were deleted (local/forwarded address helpers).
src/FeatureManagement/README.md Documents that the filter uses RemoteIpAddress and requires trusted Forwarded Headers Middleware when behind proxies.
src/FeatureManagement/Filters/IPAddressFilter.cs Implements the security change: evaluate only Connection.RemoteIpAddress.
src/FeatureManagement/Extensions/HttpContextExtensions.cs Removes IsLocal / GetForwardedAddress and associated parsing logic.
src/FeatureManagement/Constants/RequestParameters.cs Removes the X-Forwarded-For header constant since it’s no longer used/parsed.
.github/copilot-instructions.md Adds/updates repository guidance to prevent reintroducing forwarded-header parsing/bypass behavior.

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

@microsoft-omex

microsoft-omex Bot commented Aug 25, 2026

Copy link
Copy Markdown

PR Metrics

Thanks for keeping your pull request small.
Thanks for adding tests.

Lines
Product Code 1
Test Code 26
Subtotal 27
Ignored Code 5
Total 32

Metrics computed by PR Metrics. Add it to your Azure DevOps and GitHub PRs!

@microsoft-omex microsoft-omex Bot changed the title Secure IP Address Filtering XS✔ ◾ Secure IP Address Filtering Aug 25, 2026

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.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Comment thread tests/FeatureManagement.UnitTests/Filters/IPAddressFilterTests.cs
Co-authored-by: muiriswoulfe <36772829+muiriswoulfe@users.noreply.github.com>

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.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

Copilot AI deployed to github-app-main August 25, 2026 15:28 Active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants