Skip to content

ftplib should not use the host from the PASV response #87451

Closed

Description

@ricexdream
BPO 43285
Nosy @gpshead, @giampaolo, @ned-deily, @miss-islington
PRs
  • bpo-43285 Make ftplib not trust the PASV response. #24838
  • [3.9] bpo-43285 Make ftplib not trust the PASV response. (GH-24838) #24880
  • [3.8] bpo-43285 Make ftplib not trust the PASV response. (GH-24838) #24881
  • [3.6] bpo-43285 Make ftplib not trust the PASV response. (GH-24838) (GH-24881) #24882
  • [3.7] bpo-43285 Make ftplib not trust the PASV response. (GH-24838) (GH-24881) #24883
  • bpo-43285: Whats New entry for 3.8.9. #24886
  • bpo-43285: Add a What's New entry for 3.9.3. #24887
  • [3.9] bpo-43285: Add a What's New entry for 3.9.3. #24888
  • [3.8] bpo-43285: Whats New entry for 3.8.9. #24889
  • 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 = None
    closed_at = <Date 2021-03-16.21:54:25.203>
    created_at = <Date 2021-02-21.11:49:34.689>
    labels = ['type-security', '3.7', 'library', 'release-blocker']
    title = 'ftplib should not use the host from the PASV response'
    updated_at = <Date 2021-03-16.21:54:25.202>
    user = 'https://bugs.python.org/ricexdream'

    bugs.python.org fields:

    activity = <Date 2021-03-16.21:54:25.202>
    actor = 'ned.deily'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-03-16.21:54:25.203>
    closer = 'ned.deily'
    components = ['Library (Lib)']
    creation = <Date 2021-02-21.11:49:34.689>
    creator = 'ricexdream'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 43285
    keywords = ['patch']
    message_count = 16.0
    messages = ['387455', '388267', '388602', '388610', '388757', '388761', '388762', '388763', '388768', '388777', '388812', '388813', '388815', '388882', '388885', '388891']
    nosy_count = 5.0
    nosy_names = ['gregory.p.smith', 'giampaolo.rodola', 'ned.deily', 'miss-islington', 'ricexdream']
    pr_nums = ['24838', '24880', '24881', '24882', '24883', '24886', '24887', '24888', '24889']
    priority = 'release blocker'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'security'
    url = 'https://bugs.python.org/issue43285'
    versions = ['Python 3.6', 'Python 3.7']

    Linked PRs

    Activity

    1. self-assigned this
      on Mar 13, 2021
    2. gpshead commented on Mar 13, 2021

      @gpshead
      Member

      I'm not interested in chasing down a CVE for this myself. If anyone wants to jump through the hoops to obtain one, the text used for curl in the hackerone link is likely a good guide.

      My PR includes a way for people to opt-out of the secure behavior (why would anyone ever want that?) by setting the use_untrusted_server_pasv_ipv4_addr attribute to True on their ftplib.FTP instance. Setting that attribute on a server lacking this fix is a no-op, making it safe to add to code running on any version.

      This is an embarrassingly old widespread common issue in a large number of ftp clients. Even the 1998 IPv6 RFC https://tools.ietf.org/html/rfc2428 indirectly acknowledges its existence by disallowing the new EPSV command that replaces PASV from returning anything other than the port number while leaving fields for the other values present but empty...

    3. changed the title [-]ftplib use host from PASV response[/-] [+]ftplib should not use the host from the PASV response[/+] on Mar 13, 2021
    4. changed the title [-]ftplib use host from PASV response[/-] [+]ftplib should not use the host from the PASV response[/+] on Mar 13, 2021
    5. gpshead commented on Mar 15, 2021

      @gpshead
      Member

      New changeset 0ab152c by Gregory P. Smith in branch 'master':
      bpo-43285 Make ftplib not trust the PASV response. (GH-24838)
      0ab152c

    6. miss-islington commented on Mar 15, 2021

      @miss-islington
      Contributor

      New changeset 7dcb4ba by Miss Islington (bot) in branch '3.9':
      bpo-43285 Make ftplib not trust the PASV response. (GH-24838)
      7dcb4ba

    7. gpshead commented on Mar 15, 2021

      @gpshead
      Member

      New changeset 664d1d1 by Gregory P. Smith in branch '3.8':
      [3.8] bpo-43285 Make ftplib not trust the PASV response. (GH-24838) (GH-24881)
      664d1d1

    8. gpshead commented on Mar 15, 2021

      @gpshead
      Member

      3.7 and 3.6 backport PRs created and assigned to release manager Ned for merging.

    9. ned-deily commented on Mar 15, 2021

      @ned-deily
      Member

      @gps, What about ftplib doc changes and What's new entries for this change in behavior?

    10. gpshead commented on Mar 15, 2021

      @gpshead
      Member

      A What's New entry is a good idea. I'll make one and add it to those backport PRs. (reopened to remind me of that)

      ftplib docs... I don't actually want to document the attribute that people can set for the old behavior beyond the notes in NEWS or What's New. It is something I anticipate nobody in the world ever actually setting so I'd rather not imply that anyone even should by giving it more prominent doc space.

      Other things that have fixed this repeated bug in their program that supports ftp over the years have not added an opt-out as far as I could tell in my quick searching.

    11. gpshead commented on Mar 16, 2021

      @gpshead
      Member

      New changeset d0312ce by Gregory P. Smith in branch '3.9':
      [3.9] bpo-43285: Add a What's New entry for 3.9.3. (GH-24888)
      d0312ce

    12. gpshead commented on Mar 16, 2021

      @gpshead
      Member

      New changeset 9eda0df by Gregory P. Smith in branch '3.8':
      [3.8] bpo-43285: Whats New entry for 3.8.9. (GH-24889)
      9eda0df

    13. gpshead commented on Mar 16, 2021

      @gpshead
      Member

      3.7 and 3.6 PRs updated to include a What's New entry.

    14. ned-deily commented on Mar 16, 2021

      @ned-deily
      Member

      New changeset 4134f15 by Miss Islington (bot) in branch '3.6':
      [3.6] bpo-43285 Make ftplib not trust the PASV response. (GH-24838) (GH-24881) (GH-24882)
      4134f15

    15. ned-deily commented on Mar 16, 2021

      @ned-deily
      Member

      New changeset 7937395 by Miss Islington (bot) in branch '3.7':
      [3.7] bpo-43285 Make ftplib not trust the PASV response. (GH-24838) (GH-24881) (GH-24883)
      7937395

    16. ned-deily commented on Mar 16, 2021

      @ned-deily
      Member

      Thanks for the PRs and the What's New entries.

    17. removed their assignment
      on Mar 16, 2021
    18. removed their assignment
      on Mar 16, 2021
    19. transferred this issue fromon Apr 10, 2022
    20. added 6 commits that reference this issue on May 10, 2026
    21. added a commit that references this issue on May 18, 2026
    22. added 2 commits that reference this issue on Jun 27, 2026
    23. added 4 commits that reference this issue on Sep 18, 2026
    24. added 3 commits that reference this issue on Oct 1, 2026
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.7 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytype-securityA security issue

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions