GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [tangentially related to CVE-2023-24329] urlparse does not correctly handle schemes that begin with ASCII digits, '+', '-', and '.' characters · Issue #99418 · python/cpython

[tangentially related to CVE-2023-24329] urlparse does not correctly handle schemes that begin with ASCII digits, '+', '-', and '.' characters #99418

New issue
Copy link
New issue
Copy link
Closed
Closed
[tangentially related to CVE-2023-24329] urlparse does not correctly handle schemes that begin with ASCII digits, '+', '-', and '.' characters#99418
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@kenballus
kenballus
opened on Nov 12, 2022
Issue body actions

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 be one ASCII alpha, followed by zero or more of ASCII alphanumeric, U+002B (+), U+002D (-), and U+002E (.)."

The bug

This is the scheme string parsing code from Lib/urllib/parse.py:462-468:

    i = url.find(':')
    if i > 0:
        for c in url[:i]:
            if c not in scheme_chars:
                break
        else:
            scheme, url = url[:i].lower(), url[i+1:]

This is the definition of scheme_chars from Lib/urllib/parse.py:77-80:

scheme_chars = ('abcdefghijklmnopqrstuvwxyz'
                'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
                '0123456789'
                '+-.')

This 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.

This bug is reproducible with the following snippet:

>>> from urllib.parse import urlparse
>>> urlparse(".://") # Should error, but doesn't
ParseResult(scheme='.', netloc='', path='', params='', query='', fragment='')

My environment

  • CPython versions tested on:
    • 3.12.0a1+ (fb844e1)
    • 3.10.8
  • Operating system and architecture:
    • Arch Linux x86_64
  • PR: gh-99418: Make urllib.parse.urlparse enforce that a scheme must begin with an alphabetical ASCII character. #99421
  • PR: [3.11] gh-99418: Make urllib.parse.urlparse enforce that a scheme must begin with an alphabetical ASCII character. (GH-99421) #99446
Reacted by Gregory P. Smith and RacerZ

Activity

  1. kenballus
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Nov 12, 2022
  2. hugovk
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Nov 12, 2022
  3. gpshead
    added a commit that references this issue on Nov 13, 2022

    gh-99418: Make urllib.parse.urlparse enforce that a scheme must begin…

    439b9cf
  4. miss-islington
    added 2 commits that reference this issue on Nov 13, 2022

    pythongh-99418: Make urllib.parse.urlparse enforce that a scheme must…

    4e0f5af

    gh-99418: Make urllib.parse.urlparse enforce that a scheme must begin…

    72d356e
  5. hauntsaninja commented on Nov 29, 2022

    @hauntsaninja
    hauntsaninja
    on Nov 29, 2022
    Contributor
    More actions

    Thanks, looks like this has been fixed

  6. hauntsaninja
    closed this as completedon Nov 29, 2022
  7. vstinner commented on Apr 5, 2023

    @vstinner
    vstinner
    on Apr 5, 2023
    Member
    More actions

    CVE-2023-24329 was assigned to this issue.

  8. vstinner
    changed the title [-]urlparse does not correctly handle schemes that begin with ASCII digits, '+', '-', and '.' characters[/-] [+][CVE-2023-24329] urlparse does not correctly handle schemes that begin with ASCII digits, '+', '-', and '.' characters[/+] on Apr 5, 2023
  9. vstinner commented on Apr 5, 2023

    @vstinner
    vstinner
    on Apr 5, 2023
    Member
    More actions

    Python 3.7, 3.8 and 3.9 are affected by this issue and still get security fixes.

    @gpshead: Should this fix be backported to Python 3.7-3.9?

  10. vstinner commented on Apr 5, 2023

    @vstinner
    vstinner
    on Apr 5, 2023
    Member
    More actions

    Ah, I don't see a fix for Python 3.10 neither, whereas the issue was reported on Python 3.10.

  11. vstinner commented on Apr 5, 2023

    @vstinner
    vstinner
    on Apr 5, 2023
    Member
    More actions

    I created https://python-security.readthedocs.io/vuln/urlparse-scheme.html to track fixes of this issue.

  12. gpshead commented on Apr 8, 2023

    @gpshead
    gpshead
    on Apr 8, 2023
    Member
    More actions

    Please see #102153..

  13. gpshead commented on Apr 8, 2023

    @gpshead
    gpshead
    on Apr 8, 2023
    Member
    More actions

    (ie: that python-security urlparse-scheme blog text is currently wrong: this is not fixed, and the first report was in July, not November)

  14. vstinner commented on May 4, 2023

    @vstinner
    vstinner
    on May 4, 2023
    Member
    More actions

    (ie: that python-security urlparse-scheme blog text is currently wrong: this is not fixed, and the first report was in July, not November)

    I'm maintaining this page manually and it's quite a lot of work to maintain it. I tried to automate as many things as possible. The source can be found in the YAML file: https://github.com/vstinner/python-security/blob/main/vulnerabilities.yaml#L2134

    Free free to propose a PR to fix the entry ;-)

  15. ngie-eign commented on May 20, 2023

    @ngie-eign
    ngie-eign
    on May 20, 2023
    Contributor
    More actions

    The fix for this CVE should really be backported if applicable.

  16. gpshead
    changed the title [-][CVE-2023-24329] urlparse does not correctly handle schemes that begin with ASCII digits, '+', '-', and '.' characters[/-] [+][tangentially related to CVE-2023-24329] urlparse does not correctly handle schemes that begin with ASCII digits, '+', '-', and '.' characters[/+] on May 20, 2023
  17. gpshead commented on May 20, 2023

    @gpshead
    gpshead
    on May 20, 2023
    Member
    More actions

    The fix for this CVE should really be backported if applicable.

    This issue does not contain the fix.

    See #102153.

  18. ngie-eign commented on May 20, 2023

    @ngie-eign
    ngie-eign
    on May 20, 2023
    Contributor
    More actions

    The fix for this CVE should really be backported if applicable.

    This issue does not contain the fix.

    See #102153.

    @gpshead : thank you so very much for the pointer! I'll do some poking around next week to see if some other OS distributions have addressed this and if there aren't any available fixes, try crafting (an) appropriate patch(es) and link it/them to the appropriate issue.

    I work on a project that uses 3.8; if it's too much work for 3.7, I'll just look into making the 3.8 patch work.

  19. gentoo-bot
    added 2 commits that reference this issue on May 21, 2024

    pythongh-99418: Make urllib.parse.urlparse enforce that a scheme must…

    5355793

    pythongh-99418: Make urllib.parse.urlparse enforce that a scheme must…

    60effed
  20. gentoo-bot
    added 2 commits that reference this issue on Sep 19, 2024

    pythongh-99418: Make urllib.parse.urlparse enforce that a scheme must…

    64a1112

    pythongh-99418: Make urllib.parse.urlparse enforce that a scheme must…

    8ba4d66
  21. gentoo-bot
    added a commit that references this issue on Jul 30, 2025

    pythongh-99418: Make urllib.parse.urlparse enforce that a scheme must…

    7e53cdb
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

    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.