Commit b5c8cc6
committed
gh-127478: ftplib: prefer EPSV over PASV on IPv4 connections
makepasv() now tries EPSV (RFC 2428) before PASV when connected over
IPv4. EPSV returns only a port number without an IP address, making it
transparent to firewall FTP Application Layer Gateways (ALGs) that
intercept and often mangle PASV responses containing embedded IPs.
Falls back to PASV if the server responds with an error to EPSV.
A new class attribute FTP.prefer_epsv (default True) allows reverting
to the old PASV-first behavior when set to False.
This also fixes connectivity issues caused by the trust_server_pasv_ipv4_address
security fix (bpo-43285): when firewalls rewrite PASV responses, clients
connecting to the control channel IP on the data port often fail because
nothing is listening there. EPSV avoids this entirely since the client
always connects back to the same IP.1 parent 28eac9a commit b5c8cc6
3 files changed
Lines changed: 46 additions & 3 deletions
File tree
- Lib
- test
- Misc/NEWS.d/next/Library
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
108 | 112 | | |
109 | 113 | | |
110 | 114 | | |
| |||
322 | 326 | | |
323 | 327 | | |
324 | 328 | | |
325 | | - | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
326 | 335 | | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
327 | 343 | | |
328 | 344 | | |
329 | 345 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
181 | | - | |
| 181 | + | |
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
| |||
724 | 724 | | |
725 | 725 | | |
726 | 726 | | |
727 | | - | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
728 | 735 | | |
729 | 736 | | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
730 | 749 | | |
731 | 750 | | |
| 751 | + | |
732 | 752 | | |
733 | 753 | | |
734 | 754 | | |
| |||
739 | 759 | | |
740 | 760 | | |
741 | 761 | | |
| 762 | + | |
742 | 763 | | |
743 | 764 | | |
744 | 765 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
0 commit comments