Skip to content

Latent shift overflow in is_public's netmask (unreachable today) #372

Open

Description

@SDL-A1

is_public in crates/cli/src/public_ip.rs builds a netmask with:

let mask = u32::MAX << (32 - prefix);

For prefix == 0 that is u32::MAX << 32, which is a shift overflow:
a panic in debug builds, and an unspecified result in release.

It cannot fire today. No entry in SPECIAL_USE has a prefix of 0, and
the IANA special-purpose registry has no reason to gain one. This is a trap
for whoever adds the next block, not a live defect — raised so it is written
down rather than rediscovered.

let mask = u32::MAX.checked_shl(32 - prefix).unwrap_or(0);

Found reviewing #365, which is otherwise careful here: the block list is the
IANA registry done properly, including the 192.0.0.9 and 192.0.0.10
carve-outs for PCP and TURN anycast.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions