XS✔ ◾ Secure IP Address Filtering - #883
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Replaces #881 so the head branch is hosted directly in microsoft/Omex. The original pull request retains the earlier review timeline. |
There was a problem hiding this comment.
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
IPAddressFilterto evaluate onlyHttpContext.Connection.RemoteIpAddress(noX-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.
PR Metrics✔ Thanks for keeping your pull request small.
Metrics computed by PR Metrics. Add it to your Azure DevOps and GitHub PRs! |
Co-authored-by: muiriswoulfe <36772829+muiriswoulfe@users.noreply.github.com>
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.