Skip to content
Crypto Disclosed report Intermediate CVE-2016-0772

CVE-2016-0772 - python: smtplib StartTLS stripping attack

Python's smtplib did not raise an exception when the server's response to the STARTTLS command was unexpected, so a man-in-the-middle could inject an SMTP message that caused the client to silently skip TLS and send email in cleartext.

hxd Follow

Originally disclosed on HackerOne

Bounty$1,000 View original
  • Fixed in 47 days
  • Paid in 47 days
  • Disclosed after 3 months

python smtplib starttls stripping attack

  • affects: (basically all versions of smtplib with starttls support and projects relying on it)
  • python 2.7.2 - 2.7.11 (dates back ~14 years)
  • python 3.0 - 3.5.1 (dates back ~7 years)

Python's implementation of smtplib fails to raise an exception upon an unexpected response during negotiation of tls via the starttls protocol. This allows a MiTM capable of injecting smtp messages to force smtplib to silently abort tls negotiation proceeding to transmit cleartext. (impacting confidentiality) For more details see [1] potentially affects a variety of open source projects from Django, web2py, ...

initially reported to python PSRT (timeline see [1]) with details, PoC [2] and patch [2]. The patch was accepted and recently landed in python 2.7/3.x [3,4]. full details and the actual research material that was securely disclosed to Python PSRT will be made available at [1] (currently a preliminary vulnerability note)

the PoC striptls [2] is a generic protocol independent tls interception proxy written in python that is also capable of probing for various starttls stripping vectors in smtp, pop3, imap, ftp, xmpp, acap and irc. It is also available via pip install striptls (pretty handy for sniffing/proxying proprietary protocols based on top of implicit/explicit tls)

Vendor announcements: [5,6,7]

the preliminary vulnerability note [1] will be updated in accordance with the Python software release scheduled for June 26th.

[1] https://github.com/tintinweb/pub/tree/master/pocs/cve-2016-0772 [2] https://github.com/tintinweb/striptls [3] https://hg.python.org/cpython/rev/d590114c2394 [4] https://hg.python.org/cpython/rev/b3ce713fb9be [5] http://www.openwall.com/lists/oss-security/2016/06/14/9 [6] https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2016-0772 [7] https://access.redhat.com/security/cve/cve-2016-0772

The original report as published on HackerOne, by hxd. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Impact

A man-in-the-middle who can inject SMTP messages could force smtplib to silently abort TLS negotiation and transmit email in cleartext, affecting confidentiality.

What the attacker needed

Man-in-the-middle position; ability to inject SMTP messages

The fix

The patch was accepted and landed in Python 2.7 and 3.x.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When an email program wants to encrypt its connection, it asks the server to start TLS. The Python library smtplib did not check that the server's reply was the expected one, so an attacker in the middle of the network could send a fake reply that made the library give up on encryption without telling the user. The email would then be sent without protection, so anyone watching the network could read it.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

More by hxd

View all

3 more disclosed reports, best first.

More from Internet Bug Bounty

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.