smtplib TLS stripping


This resource is maintained for historical reference and does not contain the latest vulnerability info for Python.

The canonical database for vulnerabilities affecting Python is available on GitHub in the Open Source Vulnerability (OSV) format. This vulnerability can be viewed online at the Open Source Vulnerability Database.

A vulnerability in smtplib allowing MITM attacker to perform a startTLS stripping attack. smtplib does not seem to raise an exception when the remote end (SMTP server) is capable of negotiating starttls but fails to respond with 220 (ok) to an explicit call of SMTP.starttls(). This may allow a malicious MITM to perform a startTLS stripping attack if the client code does not explicitly check the response code for startTLS.


  • Disclosure date: 2016-06-11 (commit date)
  • Reported at: 2016-02-01 (Red Hat issue reported)
  • Reported by: Tin (Team Oststrom)

Fixed In


The smtplib library in CPython (aka Python) before 2.7.12, 3.x before 3.4.5, and 3.5.x before 3.5.2 does not return an error when StartTLS fails, which might allow man-in-the-middle attackers to bypass the TLS protections by leveraging a network position between the client and the registry to block the StartTLS command, aka a “StartTLS stripping attack.”


Timeline using the disclosure date 2016-06-11 as reference:

  • 2016-02-01 (-131 days): Reported (Red Hat issue reported)
  • 2016-06-11: Disclosure date (commit date)
  • 2016-06-11: commit 2e1b7fc (branch 2.7)
  • 2016-06-11: commit 46b32f3 (branch 3.4)
  • 2016-06-25 (+14 days): Python 2.7.12 released
  • 2016-06-25 (+14 days): Python 3.4.5 released
  • 2016-06-25 (+14 days): Python 3.5.2 released
  • 2016-09-02 (+83 days): CVE-2016-0772 published
  • 2016-12-22: Python 3.6.0 released
  • 2017-07-19 (+403 days): commit 3625f7f (branch 3.3)
  • 2017-09-19 (+465 days): Python 3.3.7 released