Skip to content

Scope Forwarded Headers Trust to Known Subnet #398

Description

@rvanmaanen

Context

Program.cs (Web) currently calls KnownIPNetworks.Clear() and KnownProxies.Clear(), which trusts all sources for X-Forwarded-For headers. This is overly permissive.

Target State

Restrict forwarded-header trust to the Azure Container Apps internal subnet range only.

Implementation

  1. Determine the Container Apps Environment internal CIDR (typically 10.0.0.0/16 or similar)
  2. Instead of clearing the lists, add only that CIDR to KnownNetworks:
options.KnownNetworks.Add(new IPNetwork(IPAddress.Parse("10.0.0.0"), 16));
  1. Make the CIDR configurable via appsettings.json for environment portability

Risk

Azure may rotate internal IPs — test thoroughly before deploying. The CIDR should be confirmed from the Container Apps Environment configuration.

Priority

Low

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions