Title: [tangentially related to CVE-2023-24329] urlparse does not correctly handle schemes that begin with ASCII digits, '+', '-', and '.' characters · Issue #99418 · python/cpython · GitHub
Open Graph Title: [tangentially related to CVE-2023-24329] urlparse does not correctly handle schemes that begin with ASCII digits, '+', '-', and '.' characters · Issue #99418 · python/cpython
X Title: [tangentially related to CVE-2023-24329] urlparse does not correctly handle schemes that begin with ASCII digits, '+', '-', and '.' characters · Issue #99418 · python/cpython
Description: Background RFC 3986 defines a scheme like this: scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) RFC 2234 defines an ALPHA like this: ALPHA = %x41-5A / %x61-7A The WHATWG URL spec defines a scheme like this: "A URL-scheme string must ...
Open Graph Description: Background RFC 3986 defines a scheme like this: scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) RFC 2234 defines an ALPHA like this: ALPHA = %x41-5A / %x61-7A The WHATWG URL spec defines a sche...
X Description: Background RFC 3986 defines a scheme like this: scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) RFC 2234 defines an ALPHA like this: ALPHA = %x41-5A / %x61-7A The ...
Opengraph URL: https://github.com/python/cpython/issues/99418
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[tangentially related to CVE-2023-24329] urlparse does not correctly handle schemes that begin with ASCII digits, '+', '-', and '.' characters","articleBody":"# Background\r\nRFC 3986 defines a scheme like this:\r\n- `scheme = ALPHA *( ALPHA / DIGIT / \"+\" / \"-\" / \".\" )`\r\n\r\nRFC 2234 defines an ALPHA like this:\r\n- `ALPHA = %x41-5A / %x61-7A`\r\n\r\nThe WHATWG URL spec defines a scheme like this:\r\n- \"A URL-scheme string must be one [ASCII alpha](https://infra.spec.whatwg.org/#ascii-alpha), followed by zero or more of [ASCII alphanumeric](https://infra.spec.whatwg.org/#ascii-alphanumeric), U+002B (+), U+002D (-), and U+002E (.).\"\r\n\r\n# The bug\r\nThis is the scheme string parsing code from `Lib/urllib/parse.py:462-468`:\r\n```python3\r\n i = url.find(':')\r\n if i \u003e 0:\r\n for c in url[:i]:\r\n if c not in scheme_chars:\r\n break\r\n else:\r\n scheme, url = url[:i].lower(), url[i+1:]\r\n```\r\nThis is the definition of `scheme_chars` from `Lib/urllib/parse.py:77-80`:\r\n```python3\r\nscheme_chars = ('abcdefghijklmnopqrstuvwxyz'\r\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\r\n '0123456789'\r\n '+-.')\r\n```\r\nThis will erroneously validate schemes that begin with any of `('.', '-', '+', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9')`. This behavior is in violation of both specifications.\r\n\r\nThis bug is reproducible with the following snippet:\r\n```python\r\n\u003e\u003e\u003e from urllib.parse import urlparse\r\n\u003e\u003e\u003e urlparse(\".://\") # Should error, but doesn't\r\nParseResult(scheme='.', netloc='', path='', params='', query='', fragment='')\r\n```\r\n\r\n# My environment\r\n- CPython versions tested on:\r\n - 3.12.0a1+ (fb844e1931bc1ad2f11565fbe25627a1a41b4203)\r\n - 3.10.8\r\n- Operating system and architecture:\r\n - Arch Linux x86_64\n\n\u003c!-- gh-pr-number: gh-99421 --\u003e\n* PR: gh-99421\n\u003c!-- /gh-pr-number --\u003e\n\n\n\u003c!-- gh-pr-number: gh-99446 --\u003e\n* PR: gh-99446\n\u003c!-- /gh-pr-number --\u003e\n","author":{"url":"https://github.com/kenballus","@type":"Person","name":"kenballus"},"datePublished":"2022-11-12T19:27:12.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":11},"url":"https://github.com/99418/cpython/issues/99418"}
| 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:b788aed9-7a95-f17c-cb29-1670c13a77e4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B9E4:358448:8DF0F:CA33B:696A3D1B |
| html-safe-nonce | 7604d0a25d61980c881b69144d22f95bd606f62b9f9a3b2fc0fbeca48b28d34f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOUU0OjM1ODQ0ODo4REYwRjpDQTMzQjo2OTZBM0QxQiIsInZpc2l0b3JfaWQiOiIxMjMxMDk1Mzg3MjQ1OTE5NTE1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 7a869ea6d5632629cdfee0223def0bfc97d849ac5f8aca947153abeee8a69122 |
| hovercard-subject-tag | issue:1446574312 |
| 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/99418/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3a9162018b23570a21a7168c86c9f556714a9be3508e7503a80a7f7b014396f9/python/cpython/issues/99418 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3a9162018b23570a21a7168c86c9f556714a9be3508e7503a80a7f7b014396f9/python/cpython/issues/99418 |
| og:image:alt | Background RFC 3986 defines a scheme like this: scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) RFC 2234 defines an ALPHA like this: ALPHA = %x41-5A / %x61-7A The WHATWG URL spec defines a sche... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kenballus |
| hostname | github.com |
| expected-hostname | github.com |
| None | 321736bfdb3f591415ae895a0459bec204b26a76caf47ba5c980634cfacc4538 |
| 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 | 13581a31d51edf4a3aca179e10890a4d4f9b6d76 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width