Title: [CVE-2024-11168] urlparse incorrectly retrieves IPv4 and regular name hosts from inside of brackets · Issue #103848 · python/cpython · GitHub
Open Graph Title: [CVE-2024-11168] urlparse incorrectly retrieves IPv4 and regular name hosts from inside of brackets · Issue #103848 · python/cpython
X Title: [CVE-2024-11168] urlparse incorrectly retrieves IPv4 and regular name hosts from inside of brackets · Issue #103848 · python/cpython
Description: Background RFC 3986 defines a host as follows host = IP-literal / IPv4address / reg-name Where IP-literal = "[" ( IPv6address / IPvFuture ) "]" reg-name = *( unreserved / pct-encoded / sub-delims ) IPv4address = dec-octet "." dec-octet "...
Open Graph Description: Background RFC 3986 defines a host as follows host = IP-literal / IPv4address / reg-name Where IP-literal = "[" ( IPv6address / IPvFuture ) "]" reg-name = *( unreserved / pct-encoded / sub-delims )...
X Description: Background RFC 3986 defines a host as follows host = IP-literal / IPv4address / reg-name Where IP-literal = "[" ( IPv6address / IPvFuture ) "]" reg-name = *( unreserved / pct-en...
Opengraph URL: https://github.com/python/cpython/issues/103848
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[CVE-2024-11168] urlparse incorrectly retrieves IPv4 and regular name hosts from inside of brackets","articleBody":"# Background\r\n\r\nRFC 3986 defines a host as follows\r\n```\r\nhost = IP-literal / IPv4address / reg-name\r\n```\r\nWhere\r\n```\r\nIP-literal = \"[\" ( IPv6address / IPvFuture ) \"]\"\r\nreg-name = *( unreserved / pct-encoded / sub-delims )\r\nIPv4address = dec-octet \".\" dec-octet \".\" dec-octet \".\" dec-octet\r\n```\r\n\r\nWhatWG says that \"A valid host string must be a [valid domain string](https://url.spec.whatwg.org/#valid-domain-string), a [valid IPv4-address string](https://url.spec.whatwg.org/#valid-ipv4-address-string), or: U+005B ([), followed by a [valid IPv6-address string](https://url.spec.whatwg.org/#valid-ipv6-address-string), followed by U+005D (]).\"\r\n\r\n# The Bug\r\n\r\nThis is code from ```Lib/urllib/parse.py:196-208``` used for retrieving the hostname from the netloc\r\n```python\r\n @property\r\n def _hostinfo(self):\r\n netloc = self.netloc\r\n _, _, hostinfo = netloc.rpartition('@')\r\n _, have_open_br, bracketed = hostinfo.partition('[')\r\n if have_open_br:\r\n hostname, _, port = bracketed.partition(']')\r\n _, _, port = port.partition(':')\r\n else:\r\n hostname, _, port = hostinfo.partition(':')\r\n if not port:\r\n port = None\r\n return hostname, port\r\n```\r\n\r\nIt will incorrectly retrieve IPv4 addresses and regular name hosts from inside brackets. This is in violation of both specifications.\r\n\r\nMinimally reproducible example:\r\n```python\r\nfrom urllib.parse import urlsplit\r\n\r\nparsedURL = urlsplit('scheme://user@[regname]/Path')\r\nprint(parsedURL.hostname) # Prints 'regname'\r\n```\r\n\r\n# Your environment\r\n\r\n\u003c!-- Include as many relevant details as possible about the environment you experienced the bug in --\u003e\r\n\r\n- CPython versions tested on:\r\n - 3.12a7 ([```23cf1e2```](https://github.com/JohnJamesUtley/cpython/commit/23cf1e20a6470588fbc64483031ceeec7614dc56))\r\n - 3.10.10\r\n- Operating system and architecture:\r\n - Arch Linux x86_64\r\n\r\n\u003c!--\r\nYou can freely edit this text. Remove any lines you believe are unnecessary.\r\n--\u003e\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-103849\n* gh-104349\n* gh-126975\n* gh-126976\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/JohnJamesUtley","@type":"Person","name":"JohnJamesUtley"},"datePublished":"2023-04-25T19:43:19.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":11},"url":"https://github.com/103848/cpython/issues/103848"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:9abbd02c-6c6f-8765-f1f0-9bfc76660ebb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A8A6:31E362:A2E1FE:DA07CA:696992BF |
| html-safe-nonce | 18ba61aa0a7f49b8968aa001492f8c6ee87d82a1d40f14b975b476bbeedeb777 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOEE2OjMxRTM2MjpBMkUxRkU6REEwN0NBOjY5Njk5MkJGIiwidmlzaXRvcl9pZCI6IjU5MTIwNDA1MDIxMDAzMzMyNDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 1ea74cc4f78f587ba717f583f794586119066c35ee2a157f4bb9eff6404601f1 |
| hovercard-subject-tag | issue:1683758204 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/103848/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d200dfb9a8851b549a262bae9fc8f38553fbe54e58bf354e4339e47cdf9465c4/python/cpython/issues/103848 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d200dfb9a8851b549a262bae9fc8f38553fbe54e58bf354e4339e47cdf9465c4/python/cpython/issues/103848 |
| og:image:alt | Background RFC 3986 defines a host as follows host = IP-literal / IPv4address / reg-name Where IP-literal = "[" ( IPv6address / IPvFuture ) "]" reg-name = *( unreserved / pct-encoded / sub-delims )... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JohnJamesUtley |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3542e147982176a7ebaa23dfb559c8af16f721c03ec560c68c56b64a0f35e751 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | af80af7cc9e3de9c336f18b208a600950a3c187c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width