Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipaddress is_private misleading for IPv4 mapped IPv6 addresses #77614

Closed
ThomasKriechbaumer mannequin opened this issue May 5, 2018 · 5 comments
Closed

ipaddress is_private misleading for IPv4 mapped IPv6 addresses #77614

ThomasKriechbaumer mannequin opened this issue May 5, 2018 · 5 comments
Labels
3.10 only security fixes 3.11 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@ThomasKriechbaumer
Copy link
Mannequin

ThomasKriechbaumer mannequin commented May 5, 2018

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']

    @ThomasKriechbaumer
    Copy link
    Mannequin Author

    ThomasKriechbaumer mannequin commented May 5, 2018

    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.

    @ThomasKriechbaumer ThomasKriechbaumer mannequin added 3.7 (EOL) end of life 3.8 only security fixes stdlib Python modules in the Lib dir labels May 5, 2018
    @JamoBox
    Copy link
    Mannequin

    JamoBox mannequin commented May 16, 2021

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

    @gpshead
    Copy link
    Member

    gpshead commented May 17, 2021

    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.

    @gpshead gpshead added 3.10 only security fixes 3.11 only security fixes type-feature A feature request or enhancement and removed 3.7 (EOL) end of life 3.8 only security fixes labels May 17, 2021
    @miss-islington
    Copy link
    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

    @gpshead
    Copy link
    Member

    gpshead commented May 17, 2021

    thanks!

    @gpshead gpshead closed this as completed May 17, 2021
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 only security fixes 3.11 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants