python / python/cpython

Change default security of `ftplib.FTP_TLS`

未关闭
#143,497 11 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

stdlib type-feature type-security
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

Bug report

Bug description:

Hi!

It has come to my attention that the ftplib.FTP_TLS class shyly notes in its documentation — it does not warning — that it is insecure by default: it leaves the data connection without TLS and vulnerable to man-in-the-middle attacks. Documenting that calling .prot_p() closes that hole is better than nothing but misses the point: vulnerable defaults need to be fixed, just XML parsers must not be vulnerable to XXE by default.

To see the issue in action, you can run this script…


# /usr/bin/env python3
# Copyright (c) 2026 Sebastian Pipping <sebastian@pipping.org>
# SPDX-License-Identifier: 0BSD

from sys import stdout
from ftplib import FTP_TLS

ftps = FTP_TLS('test.rebex.net')
ftps.login(user="demo", passwd="password")
ftps.retrbinary('RETR readme.txt', stdout.buffer.write)  # <-- MITM here
ftps.quit()

…and watch sudo tcpdump -i any -A 2>/dev/null | grep -F "Rebex FTP/SSL" output in another terminal to see the MITM in action.

A pull request with a fix and extending documention on security is upcoming.

I'm looking forward to your review and am hoping for your support 🙏

Related:

  • issue #91826 is another unfixed MITM vector due to lack of FTPS certificate validation 😞
  • issue #63699 is breaking FTPS with most servers for 12+ years now, would be great to have that fixed 🙏

CC @The-Compiler @hannob @nitram2342

CPython versions tested on:

3.9, 3.10, 3.11, 3.12, 3.13, 3.14, 3.15, CPython main branch

Operating systems tested on:

Linux, macOS, Windows, Other

Linked PRs
  • gh-143498

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 ftplib.FTP_TLS 入口点及其链接的文档开始,然后查看展示未受保护数据连接的复现。检查链接的 PR gh-143498,了解已经在进行的工作;完成后应解决不安全的默认设置,并记录由此产生的安全行为。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
security
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
20/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。