René's URL Explorer Experiment


Title: ipaddress considers some not globally reachable addresses global and vice versa · Issue #113171 · python/cpython · GitHub

Open Graph Title: ipaddress considers some not globally reachable addresses global and vice versa · Issue #113171 · python/cpython

X Title: ipaddress considers some not globally reachable addresses global and vice versa · Issue #113171 · python/cpython

Description: Bug report Bug description: Judging by what the is_private and is_global implementations in the ipaddress module do[1], everything that IANA special-purpose address registries[2][3] considers globally reachable should result in is_global...

Open Graph Description: Bug report Bug description: Judging by what the is_private and is_global implementations in the ipaddress module do[1], everything that IANA special-purpose address registries[2][3] considers globa...

X Description: Bug report Bug description: Judging by what the is_private and is_global implementations in the ipaddress module do[1], everything that IANA special-purpose address registries[2][3] considers globa...

Opengraph URL: https://github.com/python/cpython/issues/113171

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ipaddress considers some not globally reachable addresses global and vice versa","articleBody":"# Bug report\r\n\r\n### Bug description:\r\n\r\nJudging by what the `is_private` and `is_global` implementations in the `ipaddress` module do[1], everything that IANA special-purpose address registries[2][3] considers globally reachable should result in `is_global == True`, the rest should be `is_global = True`. \r\n\r\n`is_private` is almost always the opposite of `is_global` (`100.64.0.0/10` is special).\r\n\r\nThe problem is the ranges present in the code (in the `_private_networks` variables) are not quite right:\r\n\r\n* There are some ranges missing (so we incorrectly treat them as globally reachable)\r\n* Some of the ranges fail to account for more specific allocations defined as globally reachable (so we incorrectly treat them as not globally reachable)\r\n\r\nThis is what I have right now and I'll submit that as a PR:\r\n\r\n```diff\r\ndiff --git a/Lib/ipaddress.py b/Lib/ipaddress.py\r\nindex 5b5520b92bde..3ee565bcd30b 100644\r\n--- a/Lib/ipaddress.py\r\n+++ b/Lib/ipaddress.py\r\n@@ -1558,13 +1558,18 @@ class _IPv4Constants:\r\n \r\n     _public_network = IPv4Network('100.64.0.0/10')\r\n \r\n+    # Not globally reachable address blocks listed on\r\n+    # https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml\r\n     _private_networks = [\r\n         IPv4Network('0.0.0.0/8'),\r\n         IPv4Network('10.0.0.0/8'),\r\n+        # 100.64.0.0/10 missing\r\n         IPv4Network('127.0.0.0/8'),\r\n         IPv4Network('169.254.0.0/16'),\r\n         IPv4Network('172.16.0.0/12'),\r\n+        # Incomplete. Should be 192.0.0.0/24 - (192.0.0.9/32 + 192.0.0.10/32)\r\n         IPv4Network('192.0.0.0/29'),\r\n+        # 192.0.0.8/32 missing\r\n         IPv4Network('192.0.0.170/31'),\r\n         IPv4Network('192.0.2.0/24'),\r\n         IPv4Network('192.168.0.0/16'),\r\n@@ -2306,15 +2311,31 @@ class _IPv6Constants:\r\n \r\n     _multicast_network = IPv6Network('ff00::/8')\r\n \r\n+    # Not globally reachable address blocks listed on\r\n+    # https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml\r\n     _private_networks = [\r\n         IPv6Network('::1/128'),\r\n         IPv6Network('::/128'),\r\n         IPv6Network('::ffff:0:0/96'),\r\n+        # 64:ff9b:1::/48 missing\r\n         IPv6Network('100::/64'),\r\n+        # Not quite right as there are multiple more specific allocations that are globally\r\n+        # reachable. Should be:\r\n+        # 2001::/23 - (\r\n+        #     2001:1::1/128\r\n+        #     + 2001:1::2/128\r\n+        #     + 2001:3::/32\r\n+        #     + 2001:4:112::/48\r\n+        #     + 2001:20::/28\r\n+        #     + 2001:30::/28\r\n+        # )\r\n         IPv6Network('2001::/23'),\r\n+        # Unnecessary, covered by 2001::/23\r\n         IPv6Network('2001:2::/48'),\r\n         IPv6Network('2001:db8::/32'),\r\n+        # Unnecessary, covered by 2001::/23\r\n         IPv6Network('2001:10::/28'),\r\n+        # Potentially 2002::/16 missing? IANA says N/A, there is no true/false value\r\n         IPv6Network('fc00::/7'),\r\n         IPv6Network('fe80::/10'),\r\n         ]\r\n```\r\n\r\n[1] And which should really be documented per #65056 – a separate issue though\r\n[2] https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml\r\n[3] https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml\r\n\r\n### CPython versions tested on:\r\n\r\nCPython main branch\r\n\r\n### Operating systems tested on:\r\n\r\n_No response_\r\n\r\n\u003c!-- gh-linked-prs --\u003e\r\n### Linked PRs\r\n* gh-113179\r\n* gh-118177\n* gh-118227\n* gh-118229\n* gh-118472\n* gh-118479\n\u003c!-- /gh-linked-prs --\u003e\r\n","author":{"url":"https://github.com/jstasiak","@type":"Person","name":"jstasiak"},"datePublished":"2023-12-15T13:58:56.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/113171/cpython/issues/113171"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:bdbb39e8-5cc4-8963-bdb3-ef0abdeaaaa5
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idCE04:1025CE:4BD81F:65FCCC:6969B0BC
html-safe-nonce2b298c565ebb5502d8aa11bfd8a1628e4a5bf62c4596f6eb9259147a14f3a8fb
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRTA0OjEwMjVDRTo0QkQ4MUY6NjVGQ0NDOjY5NjlCMEJDIiwidmlzaXRvcl9pZCI6IjQ0ODYwMDU0NTg4MTk3MjM0NTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacd883f1ae515be787acb57cd86c74051727e4b1f4e9549cf88a5c879d5af29dc9
hovercard-subject-tagissue:2043777514
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/113171/issue_layout
twitter:imagehttps://opengraph.githubassets.com/2720f01c19477d24e5eecb51280cd1ba0afbc8cedc071337ee20f4669b0612da/python/cpython/issues/113171
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/2720f01c19477d24e5eecb51280cd1ba0afbc8cedc071337ee20f4669b0612da/python/cpython/issues/113171
og:image:altBug report Bug description: Judging by what the is_private and is_global implementations in the ipaddress module do[1], everything that IANA special-purpose address registries[2][3] considers globa...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamejstasiak
hostnamegithub.com
expected-hostnamegithub.com
Noneb23b8fcc855cd29bb04d6c94aafa62d336bf44eefa8229444eecc968cad03aee
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release0672399d88424758731ec07fe24509e23bb17fb5
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/issues/113171#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F113171
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F113171
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/113171
Reloadhttps://github.com/python/cpython/issues/113171
Reloadhttps://github.com/python/cpython/issues/113171
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/issues/113171
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 33.9k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 71.1k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.1k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects 31 https://github.com/python/cpython/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/python/cpython/security
Please reload this pagehttps://github.com/python/cpython/issues/113171
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/113171
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/113171
ipaddress considers some not globally reachable addresses global and vice versahttps://github.com/python/cpython/issues/113171#top
https://github.com/encukou
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
type-securityA security issuehttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-security%22
https://github.com/jstasiak
https://github.com/jstasiak
jstasiakhttps://github.com/jstasiak
on Dec 15, 2023https://github.com/python/cpython/issues/113171#issue-2043777514
#65056https://github.com/python/cpython/issues/65056
https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtmlhttps://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml
https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtmlhttps://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml
GH-113171: Fix "private" (non-global) IP address ranges #113179https://github.com/python/cpython/pull/113179
[3.12] gh-113171: gh-65056: Fix "private" (non-global) IP address ranges (GH-113179) (GH-113186) #118177https://github.com/python/cpython/pull/118177
[3.11] gh-113171: gh-65056: Fix "private" (non-global) IP address ranges (GH-113179) (GH-113186) (GH-118177) #118227https://github.com/python/cpython/pull/118227
[3.10] gh-113171: gh-65056: Fix "private" (non-global) IP address ranges (GH-113179) (GH-113186) (GH-118177) #118229https://github.com/python/cpython/pull/118229
[3.9] gh-113171: gh-65056: Fix "private" (non-global) IP address ranges (GH-113179) (GH-113186) (GH-118177) #118472https://github.com/python/cpython/pull/118472
[3.8] gh-113171: gh-65056: Fix "private" (non-global) IP address ranges (GH-113179) (GH-113186) (GH-118177) #118479https://github.com/python/cpython/pull/118479
encukouhttps://github.com/encukou
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
type-securityA security issuehttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-security%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.