Skip to content

Scope Forwarded Headers Trust to Known Subnet #398

@rvanmaanen

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions