Commit graph

24472 commits

Author SHA1 Message Date
Steve Dower
5130731c9e
[3.9] gh-118486: Support mkdir(mode=0o700) on Windows (GH-118488) (GH-118741)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-05-24 19:27:01 +02:00
Seth Michael Larson
b228655c22
[3.9] gh-114572: Fix locking in cert_store_stats and get_ca_certs (#118109) 2024-05-10 13:46:12 +02:00
Petr Viktorin
22adf29da8
[3.9] gh-113171: gh-65056: Fix "private" (non-global) IP address ranges (GH-113179) (GH-113186) (GH-118177) (GH-118472)
The _private_networks variables, used by various is_private
implementations, were missing some ranges and at the same time had
overly strict ranges (where there are more specific ranges considered
globally reachable by the IANA registries).

This patch updates the ranges with what was missing or otherwise
incorrect.

100.64.0.0/10 is left alone, for now, as it's been made special in [1].

The _address_exclude_many() call returns 8 networks for IPv4, 121
networks for IPv6.

[1] https://github.com/python/cpython/issues/61602

In 3.10 and below, is_private checks whether the network and broadcast
address are both private.
In later versions (where the test wss backported from), it checks
whether they both are in the same private network.

For 0.0.0.0/0, both 0.0.0.0 and 255.225.255.255 are private,
but one is in 0.0.0.0/8 ("This network") and the other in
255.255.255.255/32 ("Limited broadcast").

---------

Co-authored-by: Jakub Stasiak <jakub@stasiak.at>
2024-05-07 11:57:58 +02:00
Seth Michael Larson
7db40cd3a9
[3.9] gh-116741: Upgrade libexpat to 2.6.2 (GH-117296) (GH-118187)
(cherry picked from commit c9829eec08)
2024-05-07 10:50:48 +02:00
jkriegshauser
40d77b9367
[3.9] gh-116773: Fix overlapped memory corruption crash (GH-116774) (GH-117080)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-03-27 16:24:46 +01:00
Miss Islington (bot)
f7c7e72a1c
[3.9] gh-117187: Fix XML tests for vanilla Expat <2.6.0 (GH-117203) (GH-117247)
This fixes XML unittest fallout from the https://github.com/python/cpython/issues/115398 security fix.  When configured using `--with-system-expat` on systems with older pre 2.6.0 versions of libexpat, our unittests were failing.

(cherry picked from commit 9f74e86c78)

Co-authored-by: Sebastian Pipping <sebastian@pipping.org>
2024-03-27 14:45:22 +01:00
Łukasz Langa
882f62bd93
Python 3.9.19 2024-03-19 16:48:02 +01:00
Miss Islington (bot)
fc2c98f92f
[3.9] gh-115197: Stop resolving host in urllib.request proxy bypass (GH-115210) (GH-116068)
Use of a proxy is intended to defer DNS for the hosts to the proxy itself, rather than a potential for information leak of the host doing DNS resolution itself for any reason.  Proxy bypass lists are strictly name based.  Most implementations of proxy support agree.
(cherry picked from commit c43b26d02e)

Co-authored-by: Weii Wang <weii.wang@canonical.com>
2024-03-19 11:53:42 +01:00
Sebastian Pipping
200762426b
[3.9] gh-115398: Expose Expat >=2.6.0 reparse deferral API (CVE-2023-52425) (GH-115623) (GH-116272)
Allow controlling Expat >=2.6.0 reparse deferral (CVE-2023-52425) by adding five new methods:

- `xml.etree.ElementTree.XMLParser.flush`
- `xml.etree.ElementTree.XMLPullParser.flush`
- `xml.parsers.expat.xmlparser.GetReparseDeferralEnabled`
- `xml.parsers.expat.xmlparser.SetReparseDeferralEnabled`
- `xml.sax.expatreader.ExpatParser.flush`

Based on the "flush" idea from https://github.com/python/cpython/pull/115138#issuecomment-1932444270 .

Includes code suggested-by: Snild Dolkow <snild@sony.com>
and by core dev Serhiy Storchaka.

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2024-03-07 00:03:30 +01:00
Miss Islington (bot)
468ba95c79
[3.9] gh-107077: Raise SSLCertVerificationError even if the error is set via SSL_ERROR_SYSCALL (GH-107586) (#107590)
(cherry picked from commit 77e09192b5)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: T. Wouters <thomas@python.org>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-02-21 17:02:34 +01:00
Seth Michael Larson
4b68e5d7ab
[3.9] Upgrade bundled libexpat to 2.6.0 (GH-115399) (GH-115474)
Manual backport due to code differences.
(cherry picked from commit e071b0d558)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-02-21 13:48:13 +01:00
Miss Islington (bot)
0397866920
[3.9] gh-115399: Document CVE-2023-52425 under "XML vulnerabilities" (GH-115400) (GH-115763)
Doc/library/xml.rst: Document CVE-2023-52425 under "XML vulnerabilities"
(cherry picked from commit fbd40ce46e)

Co-authored-by: Sebastian Pipping <sebastian@pipping.org>
2024-02-21 12:45:14 +01:00
Seth Michael Larson
dafb4f0c6b
[3.9] Fix tests for XMLPullParser with Expat 2.6.0 (GH-115133) (GH-115535)
Feeding the parser by too small chunks defers parsing to prevent
CVE-2023-52425. Future versions of Expat may be more reactive.
(cherry picked from commit 4a08e7b343)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-02-21 12:22:55 +01:00
Miss Islington (bot)
fa1f564118
[3.9] Add missing sections to blurbs (GH-114553) (GH-115339)
(cherry picked from commit dc8893af7d)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-02-13 13:56:31 +01:00
Łukasz Langa
24c6514765
[3.9] gh-111239: Update Windows build to use zlib 1.3.1 (GH-114877) (GH-115087)
(cherry picked from commit 618d7256e7)

Co-authored-by: Zachary Ware <zach@python.org>
2024-02-06 16:08:31 +01:00
Serhiy Storchaka
8fc8c45b67
[3.9] gh-113659: Skip hidden .pth files (GH-113660) (GH-114146)
(cherry picked from commit 74208ed0c4)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-01-17 15:28:17 +01:00
Miss Islington (bot)
a2c59992e9
[3.9] gh-109858: Protect zipfile from "quoted-overlap" zipbomb (GH-110016) (GH-113915)
Raise BadZipFile when try to read an entry that overlaps with other entry or
central directory.
(cherry picked from commit 66363b9a7b)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-01-17 14:48:06 +01:00
Serhiy Storchaka
d54e22a669
[3.9] gh-91133: tempfile.TemporaryDirectory: fix symlink bug in cleanup (GH-99930) (GH-112842)
(cherry picked from commit 81c16cd94e)

Co-authored-by: Søren Løvborg <sorenl@unity3d.com>
2024-01-17 14:47:47 +01:00
Miss Islington (bot)
a6f73f6114
[3.9] bpo-37013: Fix the error handling in socket.if_indextoname() (GH-13503) (GH-112600)
* Fix a crash when pass UINT_MAX.
* Fix an integer overflow on 64-bit non-Windows platforms.
(cherry picked from commit 0daf555c6f)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2024-01-17 14:47:26 +01:00
Zachary Ware
75da5067cf
[3.9] gh-109991: Update Windows build to use OpenSSL 1.1.1w (GH-111265)
(cherry picked from commit dcb16c98be)

Co-authored-by: Steve Dower <steve.dower@python.org>
2024-01-17 14:47:09 +01:00
Ned Deily
f4118e9995
[3.9] gh-109991: Update GitHub CI workflows to use OpenSSL 3.0.11 and multissltests to use 1.1.1w and 3.0.11. (GH-110008)
(cherry picked from commit c88037d137)
2024-01-17 14:46:46 +01:00
Łukasz Langa
08b640e157
[3.9] gh-101180: Fix a bug where iso2022_jp_3 and iso2022_jp_2004 codecs read out of bounds (gh-111695) (gh-111780)
(cherry picked from commit c8faa3568a)

Co-authored-by: Masayuki Moriyama <masayuki.moriyama@miraclelinux.com>
2023-11-06 18:44:50 +01:00
Łukasz Langa
376d66eb50
Python 3.9.18 2023-08-24 19:59:28 +02:00
Ned Deily
d31ae21e5d
[3.9] gh-107565: Update multissltests and GitHub CI workflows to use OpenSSL 1.1.1v, 3.0.10, and 3.1.2. (#108123)
[3.9] gh-107565: Update multissltests and GitHub CI workflows to use  OpenSSL 1.1.1v, 3.0.10, and 3.1.2.

(cherry picked from commit 441797d4ff)
2023-08-22 20:28:57 +02:00
Petr Viktorin
42deeab5b2
[3.9] gh-107845: Fix symlink handling for tarfile.data_filter (GH-107846) (#108274)
(cherry picked from commit acbd3f9c5c)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Lumír 'Frenzy' Balhar <frenzy.madness@gmail.com>
2023-08-22 20:28:10 +02:00
Serhiy Storchaka
4a79328195
[3.9] gh-99612: Fix PyUnicode_DecodeUTF8Stateful() for ASCII-only data (GH-99613) (GH-107224) (#107231)
Previously *consumed was not set in this case.
(cherry picked from commit f08e52ccb0).
(cherry picked from commit b8b3e6afc0)
2023-08-22 20:25:15 +02:00
Łukasz Langa
264b1dacc6
[3.9] gh-108310: Fix CVE-2023-40217: Check for & avoid the ssl pre-close flaw (#108320)
gh-108310: Fix CVE-2023-40217: Check for & avoid the ssl pre-close flaw

Instances of `ssl.SSLSocket` were vulnerable to a bypass of the TLS handshake
and included protections (like certificate verification) and treating sent
unencrypted data as if it were post-handshake TLS encrypted data.

The vulnerability is caused when a socket is connected, data is sent by the
malicious peer and stored in a buffer, and then the malicious peer closes the
socket within a small timing window before the other peers’ TLS handshake can
begin. After this sequence of events the closed socket will not immediately
attempt a TLS handshake due to not being connected but will also allow the
buffered data to be read as if a successful TLS handshake had occurred.

Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
2023-08-22 19:57:10 +02:00
Łukasz Langa
0d3cd4eb66
Python 3.9.17 2023-06-06 11:32:53 +02:00
Gregory P. Smith
e15de14c16
[3.9] gh-103142: Upgrade binary builds and CI to OpenSSL 1.1.1u (GH-105174) (GH-105200) (#105205)
Upgrade builds to OpenSSL 1.1.1u.

Also updates _ssl_data_111.h from OpenSSL 1.1.1u, _ssl_data_300.h from 3.0.9.

Manual edits to the _ssl_data_300.h file prevent it from removing any
existing definitions in case those exist in some peoples builds and were
important (avoiding regressions during backporting).

(cherry picked from commit ede89af)

Co-authored-by: Ned Deily <nad@python.org>
2023-06-05 17:41:51 +02:00
Miss Islington (bot)
d7f8a5fe07
[3.9] gh-102153: Start stripping C0 control and space chars in urlsplit (GH-102508) (GH-104575) (GH-104592) (#104593)
gh-102153: Start stripping C0 control and space chars in `urlsplit` (GH-102508)

`urllib.parse.urlsplit` has already been respecting the WHATWG spec a bit GH-25595.

This adds more sanitizing to respect the "Remove any leading C0 control or space from input" [rule](https://url.spec.whatwg.org/GH-url-parsing:~:text=Remove%20any%20leading%20and%20trailing%20C0%20control%20or%20space%20from%20input.) in response to [CVE-2023-24329](https://nvd.nist.gov/vuln/detail/CVE-2023-24329).

I simplified the docs by eliding the state of the world explanatory
paragraph in this security release only backport.  (people will see
that in the mainline /3/ docs)

(cherry picked from commit 2f630e1ce1)
(cherry picked from commit 610cc0ab1b)
(cherry picked from commit f48a96a280)

Co-authored-by: Illia Volochii <illia.volochii@gmail.com>
Co-authored-by: Gregory P. Smith [Google] <greg@krypto.org>
2023-05-22 12:42:37 +02:00
Miss Islington (bot)
3d5dd1eee2
[3.9] gh-99889: Fix directory traversal security flaw in uu.decode() (GH-104096) (#104331)
(cherry picked from commit 0aeda29793)

Co-authored-by: Sam Carroll <70000253+samcarroll42@users.noreply.github.com>
2023-05-22 12:41:30 +02:00
Miss Islington (bot)
b53d0ff431
[3.9] gh-104049: do not expose on-disk location from SimpleHTTPRequestHandler (GH-104067) (#104120)
Do not expose the local server's on-disk location from `SimpleHTTPRequestHandler` when generating a directory index. (unnecessary information disclosure)

(cherry picked from commit c7c3a60c88)

Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-05-22 12:40:50 +02:00
Steve Dower
d1645ce4f1
[3.9] gh-103935: Use io.open_code() when executing code in trace and profile modules (GH-103947) (#103953)
Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
2023-05-22 12:40:30 +02:00
Petr Viktorin
98016f7c92
[3.9] gh-102950: Implement PEP 706 – Filter for tarfile.extractall (GH-102953) (#104382)
Backport of c8c3956d90
2023-05-15 18:53:58 +02:00
Kumar Aditya
7cb3a44747
[3.9] GH-102126: fix deadlock at shutdown when clearing thread states (GH-102222) (#102236)
(cherry picked from commit 5f11478ce7)
2023-03-28 10:55:36 +02:00
Pradyun Gedam
b5a94301a2
[3.9] gh-101997: Update bundled pip version to 23.0.1 (GH-101998). (#102243)
(cherry picked from commit 89d9ff0f48)
2023-03-28 10:52:56 +02:00
Steve Dower
bf99e19b99
[3.9] gh-101726: Update the OpenSSL version to 1.1.1t (GH-101727) (GH-101751)
Fixes CVE-2023-0286 (High) and a couple of Medium security issues.
https://www.openssl.org/news/secadv/20230207.txt

Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Ned Deily <nad@python.org>
2023-03-07 18:01:22 -05:00
Miss Islington (bot)
04cc427025
[3.9] gh-101283: Improved fallback logic for subprocess with shell=True on Windows (GH-101286) (#101709)
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
Co-authored-by: Steve Dower <steve.dower@microsoft.com>
2023-02-09 10:59:40 +01:00
Steve Dower
fcfa505b80
[3.9] gh-100180: Update Windows installer to OpenSSL 1.1.1s (GH-100903) (#100904) 2023-01-20 23:22:50 +01:00
Kumar Aditya
6954203c9f
[3.9] GH-100892: Fix race in clearing threading.local (GH-100922) (#100939)
[3.9] [3.10] GH-100892: Fix race in clearing `threading.local` (GH-100922).
(cherry picked from commit 762745a124)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>.
(cherry picked from commit 683e9fe30e)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2023-01-20 23:21:40 +01:00
Éric
6be2e0e247
[3.9] gh-95778: add doc missing in some places (GH-100627). (#101066)
(cherry picked from commit 46521826cb)

Co-authored-by: Éric <earaujo@caravan.coop>
2023-01-20 23:21:00 +01:00
Łukasz Langa
595f9ccb0c
Python 3.9.16 2022-12-06 18:59:46 +01:00
Miss Islington (bot)
3b81c13ac3
[3.9] gh-100001: Omit control characters in http.server stderr logs. (GH-100002) (#100032)
* gh-100001: Omit control characters in http.server stderr logs. (GH-100002)

Replace control characters in http.server.BaseHTTPRequestHandler.log_message with an escaped \xHH sequence to avoid causing problems for the terminal the output is printed to.
(cherry picked from commit d8ab0a4dfa)

Co-authored-by: Gregory P. Smith <greg@krypto.org>

* also escape \s (backport of PR #100038).

* add versionadded and remove extra 'to'

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2022-12-06 11:22:12 +01:00
Steve Dower
7b98207aa4
[3.9] gh-87604: Avoid publishing list of active per-interpreter audit hooks via the gc module (GH-99373) (GH-99493) 2022-11-21 19:13:33 +01:00
Miss Islington (bot)
c09dba57cf
[3.9] gh-98433: Fix quadratic time idna decoding. (GH-99092) (GH-99222) (#99230)
There was an unnecessary quadratic loop in idna decoding. This restores
the behavior to linear.

(cherry picked from commit d315722564)
(cherry picked from commit a6f6c3a3d6)

Co-authored-by: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2022-11-10 16:57:41 +01:00
Miss Islington (bot)
b43496c01a
[3.9] gh-97514: Don't use Linux abstract sockets for multiprocessing (GH-98501) (#98504)
Linux abstract sockets are insecure as they lack any form of filesystem
permissions so their use allows anyone on the system to inject code into
the process.

This removes the default preference for abstract sockets in
multiprocessing introduced in Python 3.9+ via
https://github.com/python/cpython/pull/18866 while fixing
https://github.com/python/cpython/issues/84031.

Explicit use of an abstract socket by a user now generates a
RuntimeWarning.  If we choose to keep this warning, it should be
backported to the 3.7 and 3.8 branches.
(cherry picked from commit 49f61068f4)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2022-10-28 12:08:30 +02:00
Miss Islington (bot)
857efee6d2
[3.9] gh-98517: Fix buffer overflows in _sha3 module (GH-98519) (#98526)
This is a port of the applicable part of XKCP's fix [1] for
CVE-2022-37454 and avoids the segmentation fault and the infinite
loop in the test cases published in [2].

[1]: fdc6fef075
[2]: https://mouha.be/sha-3-buffer-overflow/

Regression test added by: Gregory P. Smith [Google LLC] <greg@krypto.org>
(cherry picked from commit 0e4e058602)

Co-authored-by: Theo Buehler <botovq@users.noreply.github.com>
2022-10-28 12:08:06 +02:00
Miss Islington (bot)
71a075aaee
[3.9] gh-98739: Update libexpat from 2.4.9 to 2.5.0 (GH-98742) (#98786)
Update libexpat from 2.4.9 to 2.5.0 to address CVE-2022-43680.

Co-authored-by: Shaun Walbridge <shaun.walbridge@gmail.com>
(cherry picked from commit 3e07f827b3)
2022-10-28 12:07:32 +02:00
Miss Islington (bot)
c59a16e2c7
[3.9] gh-68966: Make mailcap refuse to match unsafe filenames/types/params (GH-91993) (#98190)
gh-68966: Make mailcap refuse to match unsafe filenames/types/params (GH-91993)
(cherry picked from commit b9509ba7a9)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2022-10-11 23:13:18 +02:00
Łukasz Langa
7e28154196
Python 3.9.15 2022-10-11 16:48:37 +02:00