PSF-2026-24: FTP PASV SSRF, ftpcp() does not use actual peer address, trusts server-supplied PASV host address

Published May 13, 2026
·
Updated

The ftpcp() function in Lib/ftplib.py was not updated when CVE-2021-4189 was fixed. While makepasv() was patched to replace server-supplied PASV host addresses with the actual peer address (getpeername()[0]), ftpcp() still calls parse227() directly and passes the raw attacker-controllable IP address and port to target.sendport(). This patch is related to CVE-2021-4189.

Affected Software

1 affected component
Python Software Foundation CPython

Event History

May 13, 2026
CVE Published
via OSV·08:14 PM
Data Sourced
via OSV·08:14 PM
DescriptionSeverityWeakness

Frequently Asked Questions

1

What conditions are required to exploit this issue?

An attacker must be able to act as, or control, the FTP server used by an application that calls ftpcp(). They can supply a PASV response containing an attacker-controlled IP address and port, which ftpcp() passes to target.sendport().

2

Which code path is affected, and is the existing PASV hardening sufficient?

The affected path is ftpcp() in Lib/ftplib.py. The makepasv() hardening that substitutes the actual FTP peer address does not protect ftpcp(), because ftpcp() directly calls parse227() and uses the server-supplied address.

3

How can an organization determine whether it is exposed?

Review applications that use Python's ftplib.ftpcp() function, particularly where the FTP server endpoint may be untrusted or attacker-controlled. Uses limited to trusted FTP servers do not remove the vulnerable behavior, but reduce the opportunity for an attacker to provide a malicious PASV response.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203