Skip to content

ipaddress is_private misleading for IPv4 mapped IPv6 addresses #77614

Closed

Description

@ThomasKriechbaumer
BPO 33433
Nosy @gpshead, @miss-islington, @JamoBox
PRs
  • bpo-33433 Fix private address checking for IPv4 mapped IPv6. #26172
  • [3.10] bpo-33433 Fix private address checking for IPv4 mapped IPv6. (GH-26172) #26189
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-05-17.19:43:01.443>
    created_at = <Date 2018-05-05.13:34:54.127>
    labels = ['type-feature', 'library', '3.10', '3.11']
    title = 'ipaddress is_private misleading for IPv4 mapped IPv6 addresses'
    updated_at = <Date 2021-05-17.19:43:01.442>
    user = 'https://bugs.python.org/ThomasKriechbaumer'

    bugs.python.org fields:

    activity = <Date 2021-05-17.19:43:01.442>
    actor = 'gregory.p.smith'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-05-17.19:43:01.443>
    closer = 'gregory.p.smith'
    components = ['Library (Lib)']
    creation = <Date 2018-05-05.13:34:54.127>
    creator = 'Thomas Kriechbaumer'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 33433
    keywords = ['patch']
    message_count = 5.0
    messages = ['316213', '393749', '393789', '393823', '393824']
    nosy_count = 4.0
    nosy_names = ['gregory.p.smith', 'miss-islington', 'Thomas Kriechbaumer', 'Wicken']
    pr_nums = ['26172', '26189']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'commit review'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue33433'
    versions = ['Python 3.10', 'Python 3.11']

    Activity

    1. ThomasKriechbaumer commented on May 5, 2018

      ThomasKriechbaumermannequin
      MannequinAuthor

      ipaddress.IPv4Address and ipaddress.IPv6Address provide a is_private function that indicates if the address (or network) is part of a "private" IP range, as designated by the IANA special-use registry.

      The current documentation is as follows:

      is_private
      True if the address is allocated for private networks. See iana-ipv4-special-registry (for IPv4) or iana-ipv6-special-registry (for IPv6).

      However, IPv4-mapped IPv6 addresses are currently being reported as "private" by this function (see 22c3176#diff-0fc57874e463b95dbdfe6f80ae918ea1R1869).

      I consider this a bug or at least counter-intuitive, because e.g. ::ffff:8.8.8.8 is most definitely NOT a private IP address, and yet the ipaddress.is_private function reports True.
      The IANA special-use registry does not contain any references to "being private" for the ::ffff region. It just designates it to be used for IPv4-mapped address.

    2. JamoBox commented on May 16, 2021

      JamoBoxmannequin
      Mannequin

      I've opened a PR that should hopefully address this issue.

    3. gpshead commented on May 17, 2021

      @gpshead
      Member

      Questionable as to if this counts as a bug or not, but I agree it is counter-intuitive given the purpose of actually checking the .is_private property of an address. So updating the behavior makes sense, but I'll be conservative w.r.t. behavior changes and not apply this to a 3.9 or earlier.

    4. added
      3.11only security fixes
      type-featureA feature request or enhancement
      and removed on May 17, 2021
    5. miss-islington commented on May 17, 2021

      @miss-islington
      Contributor

      New changeset a44bb6d by Miss Islington (bot) in branch '3.10':
      bpo-33433 Fix private address checking for IPv4 mapped IPv6. (GH-26172)
      a44bb6d

    6. gpshead commented on May 17, 2021

      @gpshead
      Member

      thanks!

    7. transferred this issue fromon Apr 10, 2022
    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

      3.10 (EOL)end of life3.11only security fixesstdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions