-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
area-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.good first issueGood for newcomers.Good for newcomers.help wantedUp for grabs. We would accept a PR to help resolve this issueUp for grabs. We would accept a PR to help resolve this issue
Milestone
Description
Describe the bug
In AspNetCore/src/Middleware/HttpOverrides/src/IPNetwork.cs
The code below assumes that the prefix will have all bits in position > mask length set to 0. I do not believe that this a requirement for CIDR notation. If it is, it is not applied consistently since the routine will break if the mask is == 0 at a given byte.
for (int i = 0; i < PrefixBytes.Length && Mask[i] != 0; i++)
{
if (PrefixBytes[i] != (addressBytes[i] & Mask[i]))
{
return false;
}
}
To Reproduce
Create instance with Prefix/Prefix Length 192.168.0.1/31.
Contains returns false for 192.168.0.0.
Expected behavior
Expectation is that 192.168.0.1/31 would match 192.168.0.0
Metadata
Metadata
Assignees
Labels
area-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.good first issueGood for newcomers.Good for newcomers.help wantedUp for grabs. We would accept a PR to help resolve this issueUp for grabs. We would accept a PR to help resolve this issue