New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-43882 - urllib.parse should sanitize urls containing ASCII newline and tabs. #25595
Conversation
When you're done making the requested changes, leave the comment: |
Misc/NEWS.d/next/Security/2021-04-25-07-46-37.bpo-43882.Jpwx85.rst
Outdated
Show resolved
Hide resolved
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
….rst Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Thanks @orsenthil for the PR |
…e and tabs. (pythonGH-25595) * issue43882 - urllib.parse should sanitize urls containing ASCII newline and tabs. Co-authored-by: Gregory P. Smith <greg@krypto.org> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> (cherry picked from commit 76cd81d) Co-authored-by: Senthil Kumaran <senthil@uthcode.com>
GH-25725 is a backport of this pull request to the 3.9 branch. |
GH-25726 is a backport of this pull request to the 3.8 branch. |
…e and tabs. (pythonGH-25595) * issue43882 - urllib.parse should sanitize urls containing ASCII newline and tabs. Co-authored-by: Gregory P. Smith <greg@krypto.org> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> (cherry picked from commit 76cd81d) Co-authored-by: Senthil Kumaran <senthil@uthcode.com>
GH-25727 is a backport of this pull request to the 3.7 branch. |
…e and tabs. (pythonGH-25595) * issue43882 - urllib.parse should sanitize urls containing ASCII newline and tabs. Co-authored-by: Gregory P. Smith <greg@krypto.org> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> (cherry picked from commit 76cd81d) Co-authored-by: Senthil Kumaran <senthil@uthcode.com>
GH-25728 is a backport of this pull request to the 3.6 branch. |
…newline and tabs. (GH-25595) (GH-25725) * bpo-43882 - urllib.parse should sanitize urls containing ASCII newline and tabs. (GH-25595) Co-authored-by: Gregory P. Smith <greg@krypto.org> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> (cherry picked from commit 76cd81d) Co-authored-by: Senthil Kumaran <skumaran@gatech.edu>
…e and tabs. (pythonGH-25595) * issue43882 - urllib.parse should sanitize urls containing ASCII newline and tabs. Co-authored-by: Gregory P. Smith <greg@krypto.org> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> (cherry picked from commit 76cd81d) Co-authored-by: Senthil Kumaran <senthil@uthcode.com>
…e and tabs. (pythonGH-25595) * issue43882 - urllib.parse should sanitize urls containing ASCII newline and tabs. Co-authored-by: Gregory P. Smith <greg@krypto.org> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…newline and tabs. (pythonGH-25595) (pythonGH-25725) * bpo-43882 - urllib.parse should sanitize urls containing ASCII newline and tabs. (pythonGH-25595) Co-authored-by: Gregory P. Smith <greg@krypto.org> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> (cherry picked from commit 76cd81d) Co-authored-by: Senthil Kumaran <skumaran@gatech.edu> (backported to Python 2.7 by Michał Górny)
…newline and tabs. (pythonGH-25595) (pythonGH-25726) Co-authored-by: Gregory P. Smith <greg@krypto.org> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> (cherry picked from commit 76cd81d) Co-authored-by: Senthil Kumaran <senthil@uthcode.com> Co-authored-by: Senthil Kumaran <skumaran@gatech.edu> (cherry picked from commit 515a7bc) Co-authored-by: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
…newline and tabs. (pythonGH-25595) (pythonGH-25726) Co-authored-by: Gregory P. Smith <greg@krypto.org> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> (cherry picked from commit 76cd81d) Co-authored-by: Senthil Kumaran <senthil@uthcode.com> Co-authored-by: Senthil Kumaran <skumaran@gatech.edu> (cherry picked from commit 515a7bc) Co-authored-by: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
|
|
Implement the fix from the upstream python/cpython#25595
urlsplit was changed to strip ASCII newline and tab characters in python/cpython#25595. The urlsplit change breaks cob as it was relying on urlsplit to keep a trailing newline character. This patch is backward compatible. This issue was identified on Amazon Linux 2's Python distribution. https://alas.aws.amazon.com/AL2/ALAS-2022-1802.html. urlsplit behaviour before the fix. ``` Python 2.7.18 (default, Jun 10 2021, 00:11:02) [GCC 7.3.1 20180712 (Red Hat 7.3.1-13)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from urlparse import urlsplit >>> urlsplit("http://localhost/some-path\n").path '/some-path\n' >>> ``` urlsplit behaviour after the fix. ``` Python 2.7.18 (default, May 25 2022, 14:30:51) [GCC 7.3.1 20180712 (Red Hat 7.3.1-15)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from urlparse import urlsplit >>> urlsplit("http://localhost/some-path\n").path '/some-path' >>> ```
urlsplit function was changed to strip ASCII newline and tab characters in python/cpython#25595. The change breaks S3 authentication as cob was relying on urlsplit to keep a trailing newline character. This issue was identified on Amazon Linux 2 Python distribution which backported the change to Python 2. https://alas.aws.amazon.com/AL2/ALAS-2022-1802.html. urlsplit behaviour before the fix. ``` Python 2.7.18 (default, Jun 10 2021, 00:11:02) [GCC 7.3.1 20180712 (Red Hat 7.3.1-13)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from urlparse import urlsplit >>> urlsplit("http://localhost/some-path\n").path '/some-path\n' >>> ``` urlsplit behaviour after the fix. ``` Python 2.7.18 (default, May 25 2022, 14:30:51) [GCC 7.3.1 20180712 (Red Hat 7.3.1-15)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from urlparse import urlsplit >>> urlsplit("http://localhost/some-path\n").path '/some-path' >>> ```
urlsplit function was changed to strip ASCII newline and tab characters in python/cpython#25595. The change causes this plugin to not properly authenticate with S3, since a required newline character is no longer present. This issue was identified on Amazon Linux 2 Python distribution which backported the change to Python 2. https://alas.aws.amazon.com/AL2/ALAS-2022-1802.html. urlsplit behaviour before the fix. ``` Python 2.7.18 (default, Jun 10 2021, 00:11:02) [GCC 7.3.1 20180712 (Red Hat 7.3.1-13)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from urlparse import urlsplit >>> urlsplit("http://localhost/some-path\n").path '/some-path\n' >>> ``` urlsplit behaviour after the fix. ``` Python 2.7.18 (default, May 25 2022, 14:30:51) [GCC 7.3.1 20180712 (Red Hat 7.3.1-15)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from urlparse import urlsplit >>> urlsplit("http://localhost/some-path\n").path '/some-path' >>> ```
bpo-43882: Strip ascii newline and tabs from the url input, following WHATWG specification
Presence newline or tab characters in URL allowed attackers to write scripts in URL, hijack the web-server.
Following the controlling specification for URLs defined by WHATWG urllib.parse strips ASCII newline and tabs from the url, preventing such attacks.
https://bugs.python.org/issue43882