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 — [security] CVE-2022-0391: urllib.parse should sanitize urls containing ASCII newline and tabs. · Issue #88048 · python/cpython

[security] CVE-2022-0391: urllib.parse should sanitize urls containing ASCII newline and tabs. #88048

New issue
Copy link
New issue
Copy link
Closed
Closed
[security] CVE-2022-0391: urllib.parse should sanitize urls containing ASCII newline and tabs.#88048
Copy link
Assignees
orsenthil
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.7 (EOL)end of lifeend of life3.8 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-securityA security issueA security issue

Description

@orsenthil
orsenthil
opened on Apr 18, 2021
Issue body actions
BPO 43882
Nosy @gpshead, @orsenthil, @vstinner, @ned-deily, @OddBloke, @ambv, @mgorny, @apollo13, @mlissner, @pablogsal, @miss-islington, @tirkarthi, @felixxm, @sethmlarson
PRs
  • bpo-43882 - urllib.parse should sanitize urls containing ASCII newline and tabs. #25595
  • [3.9] bpo-43882 - urllib.parse should sanitize urls containing ASCII newline and tabs. (GH-25595) #25725
  • [3.8] bpo-43882 - urllib.parse should sanitize urls containing ASCII newline and tabs. (GH-25595) #25726
  • [3.7] bpo-43882 - urllib.parse should sanitize urls containing ASCII newline and tabs. (GH-25595) #25727
  • [3.6] bpo-43882 - urllib.parse should sanitize urls containing ASCII newline and tabs. (GH-25595) #25728
  • [3.9] bpo-43882 Remove the newline, and tab early. From query and fragments. #25853
  • bpo-43882 Remove the newline, and tab early. From query and fragments. #25921
  • [3.7] bpo-43882 - urllib.parse should sanitize urls containing ASCII newline and tabs. #25923
  • [3.6] bpo-43882 - urllib.parse should sanitize urls containing ASCII newline and tabs #25924
  • [3.10] bpo-43882 Remove the newline, and tab early. From query and fragments. (GH-25921) #25936
  • [3.7] bpo-43882 - Mention urllib.parse changes in Whats New section for 3.7.11 #26267
  • [3.6] bpo-43882 - Mention urllib.parse changes in Whats New section for 3.6.14 #26268
  • [3.10] bpo-43882 - Mention urllib.parse changes in Whats new section. #26275
  • [3.9] bpo-43882 - Mention urllib.parse changes in Whats new section. #26276
  • [3.8] bpo-43882 - Mention urllib.parse changes in Whats new section. #26277
  • 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 = 'https://github.com/orsenthil'
    closed_at = <Date 2021-06-02.01:26:09.260>
    created_at = <Date 2021-04-18.19:37:00.259>
    labels = ['type-security', '3.8', '3.9', '3.10', '3.11', '3.7', 'library']
    title = '[security] CVE-2022-0391: urllib.parse should sanitize urls containing ASCII newline and tabs.'
    updated_at = <Date 2022-02-09.11:40:17.243>
    user = 'https://github.com/orsenthil'

    bugs.python.org fields:

    activity = <Date 2022-02-09.11:40:17.243>
    actor = 'felixxm'
    assignee = 'orsenthil'
    closed = True
    closed_date = <Date 2021-06-02.01:26:09.260>
    closer = 'gregory.p.smith'
    components = ['Library (Lib)']
    creation = <Date 2021-04-18.19:37:00.259>
    creator = 'orsenthil'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 43882
    keywords = ['patch']
    message_count = 47.0
    messages = ['391343', '391352', '391426', '391859', '392334', '392338', '392611', '392781', '392808', '392835', '392873', '392926', '392944', '392971', '392995', '393009', '393025', '393030', '393033', '393034', '393039', '393049', '393107', '393108', '393136', '393139', '393142', '393144', '393146', '393149', '393150', '393198', '393203', '393205', '393207', '393211', '393997', '394056', '394057', '394058', '394062', '394112', '394113', '396628', '412688', '412705', '412821']
    nosy_count = 14.0
    nosy_names = ['gregory.p.smith', 'orsenthil', 'vstinner', 'ned.deily', 'odd_bloke', 'lukasz.langa', 'mgorny', 'apollo13', 'Mike.Lissner', 'pablogsal', 'miss-islington', 'xtreak', 'felixxm', 'sethmlarson']
    pr_nums = ['25595', '25725', '25726', '25727', '25728', '25853', '25921', '25923', '25924', '25936', '26267', '26268', '26275', '26276', '26277']
    priority = 'high'
    resolution = 'fixed'
    stage = 'commit review'
    status = 'closed'
    superseder = None
    type = 'security'
    url = 'https://bugs.python.org/issue43882'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8', 'Python 3.9', 'Python 3.10', 'Python 3.11']

    Activity

    Next
    1. orsenthil commented on Apr 18, 2021

      @orsenthil
      orsenthil
      on Apr 18, 2021
      MemberAuthor
      More actions

      A security issue was reported by Mike Lissner wherein an attacker was able to use \r\n in the url path, the urlparse method didn't sanitize and allowed those characters be present in the request.

      In [9]: from urllib.parse import urlsplit
      In [10]: urlsplit("java\nscript:alert('bad')")
      Out[10]: SplitResult(scheme='', netloc='', path="java\nscript:alert('bad')", query='', fragment='')

      Firefox and other browsers ignore newlines in the scheme. From
      the browser console:

      > new URL("java\nscript:alert(bad)")
      << URL { href: "javascript:alert(bad)", origin: "null", protocol:
      "javascript:", username: "", password: "", host: "", hostname: "", port: "", pathname: "alert(bad)", search: ""

      Mozilla Developers informed about the controlling specification for URLs is in fact defined by the "URL Spec"
      from WHATWG which updates RFC 3986 and specifies that tabs and newlines
      should be stripped from the scheme.

      See: https://url.spec.whatwg.org/#concept-basic-url-parser

      That link defines an automaton for URL parsing. From that link, steps 2 and 3 of scheme parsing read:

      If input contains any ASCII tab or newline, validation error.
      3. Remove all ASCII tab or newline from input.


      urlparse module behavior should be updated, and an ASCII tab or newline should be removed from the url (sanitized) before it is sent to the request, as WHATWG spec.

    2. orsenthil
      added
      3.10 (EOL)end of lifeend of life
      3.7 (EOL)end of lifeend of life
      3.8 (EOL)end of lifeend of life
      3.9 (EOL)end of lifeend of life
      on Apr 18, 2021
    3. orsenthil
      self-assigned this
      on Apr 18, 2021
    4. orsenthil
      added
      3.10 (EOL)end of lifeend of life
      type-securityA security issueA security issue
      3.7 (EOL)end of lifeend of life
      3.8 (EOL)end of lifeend of life
      3.9 (EOL)end of lifeend of life
      on Apr 18, 2021
    5. orsenthil
      self-assigned this
      on Apr 18, 2021
    6. orsenthil
      added
      type-securityA security issueA security issue
      on Apr 18, 2021
    7. tirkarthi commented on Apr 19, 2021

      @tirkarthi
      tirkarthi
      on Apr 19, 2021
      Member
      More actions

      See also a related issue to sanitise newline on other helper functions https://bugs.python.org/issue30713

      See also discussion and compatibility on disallowing control characters : https://bugs.python.org/issue30458

    8. vstinner
      changed the title [-]urllib.parse should sanitize urls containing ASCII newline and tabs.[/-] [+][security] urllib.parse should sanitize urls containing ASCII newline and tabs.[/+] on Apr 20, 2021
    9. 54 remaining items

    10. gpshead
      closed this as completedon Jun 2, 2021
    11. gpshead
      closed this as completedon Jun 2, 2021
    12. ambv commented on Jun 28, 2021

      @ambv
      ambv
      on Jun 28, 2021
      Contributor
      More actions

      New changeset 634da2d by Senthil Kumaran in branch '3.8':
      [3.8] bpo-43882 - Mention urllib.parse changes in Whats new section. (bpo-26277)
      634da2d

    13. vstinner commented on Feb 6, 2022

      @vstinner
      vstinner
      on Feb 6, 2022
      Member
      More actions

      CVE-2022-0391 has been assigned to this vulnerability.

    14. vstinner
      changed the title [-][security] urllib.parse should sanitize urls containing ASCII newline and tabs.[/-] [+][security] CVE-2022-0391: urllib.parse should sanitize urls containing ASCII newline and tabs.[/+] on Feb 6, 2022
    15. vstinner
      changed the title [-][security] urllib.parse should sanitize urls containing ASCII newline and tabs.[/-] [+][security] CVE-2022-0391: urllib.parse should sanitize urls containing ASCII newline and tabs.[/+] on Feb 6, 2022
    16. mlissner commented on Feb 7, 2022

      @mlissner
      mlissnermannequin
      on Feb 7, 2022
      Mannequin
      More actions

      Looks like that CVE isn't public yet.

      https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-0391

      Any chance I can get access (I originally reported this vuln.). My email is [email protected], if it's possible and my email is needed.

      Thanks!

    17. vstinner commented on Feb 8, 2022

      @vstinner
      vstinner
      on Feb 8, 2022
      Member
      More actions

      Looks like that CVE isn't public yet.
      https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-0391
      Any chance I can get access (I originally reported this vuln.).

      Message from Gaurav Kamathe who requested the CVE:

      "We've sent a request to MITRE to get this published and it'll be available on MITRE shortly."

    18. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    19. timmc commented on Aug 25, 2022

      @timmc
      timmc
      on Aug 25, 2022
      More actions

      @gpshead urlsplit already raises an exception for some malformed inputs: https://github.com/python/cpython/blob/v3.9.13/Lib/urllib/parse.py#L484 -- you can try it out with urlsplit('http://]/').

      This kind of eclectic approach -- taking part of one spec, part of another, ignoring invalid values, turning invalid outputs into answers without a warning -- is just going to cause more vulnerabilities. A URL with newlines in it was never valid, for browsers or anything else. Now there's just another parser that will give answers that don't match other parsers (whether it's browsers, or curl, or anything else). Better to bite the bullet and say "hey, that's not parseable".

    20. gpshead commented on Aug 25, 2022

      @gpshead
      gpshead
      on Aug 25, 2022
      Member
      More actions

      If you have a concrete proposal to do something different or have found other bugs, please open a new Issue. Comments added to an old merged PR are likely to be ignored and unseen.

    21. timmc commented on Aug 25, 2022

      @timmc
      timmc
      on Aug 25, 2022
      More actions

      Understood. I mostly wanted to correct the record on urlsplit's existing behavior, for people looking back at the git blame to figure out why urlsplit behaves the way it does.

      (And of course I couldn't resist tacking on a warning about parser mismatch, which I don't think got enough air time in the discussion.)

    22. parth-gr commented on Sep 5, 2022

      @parth-gr
      parth-gr
      on Sep 5, 2022
      More actions

      @orsenthil Why isn't this backported to python2?

      Should I open a manual backport of this? As it will be helpful for python2 users also

    23. gpshead commented on Sep 5, 2022

      @gpshead
      gpshead
      on Sep 5, 2022
      Member
      More actions

      python2 is EOL and receives zero support here.

      Reacted by Parth Arora and FATDEER
    24. mcepl
      added a commit that references this issue on Jun 26, 2025

      fix for santization URLs containing ASCII newline and tabs in urllib.…

      d452284
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    • @orsenthil
      orsenthil

    Labels

    3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.7 (EOL)end of lifeend of life3.8 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-securityA security issueA security issue

    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.