Skip to content

IPNetwork.Contains handles IPv4-mapped addresses inconsistently for IPv6 networks #131861

Closed

Description

@wfurt

IPNetwork.Contains uses the queried address to choose between IPv4 and IPv6 comparison logic. When an IPv4-mapped IPv6 address is queried against an IPv6 network, it can incorrectly use the IPv4 comparison path.

Expected behavior:

IPv4 networks continue to accept equivalent IPv4-mapped addresses.
IPv6 networks use IPv6 prefix semantics for all IPv6 addresses, including IPv4-mapped addresses.
Example:

IPNetwork network = IPNetwork.Parse("2a00::/13");
IPAddress address = IPAddress.Parse("::ffff:42.42.42.42");

Console.WriteLine(network.Contains(address));

The comparison path should be selected from the network’s address family rather than solely from the queried address.

Activity

  1. added this to the 11.0.0 milestone on Aug 5, 2026
  2. self-assigned this
    on Aug 5, 2026
  3. dotnet-policy-service commented on Aug 5, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @karelz, @dotnet/ncl
    See info in area-owners.md if you want to be subscribed.

  4. locked and limited conversation to collaborators on Sep 6, 2026
  5. added a commit that references this issue on Nov 17, 2026
    ee71968
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions