35bab9e
From 761db274ca898f8a92348ed5979d3d3c1b0d634a Mon Sep 17 00:00:00 2001
35bab9e
From: Tomas Orsava <torsava@redhat.com>
35bab9e
Date: Fri, 17 Jun 2016 16:08:11 +0200
35bab9e
Subject: [PATCH] Raise an error when STARTTLS fails
35bab9e
35bab9e
CVE-2016-0772 python: smtplib StartTLS stripping attack
35bab9e
rhbz#1303647: https://bugzilla.redhat.com/show_bug.cgi?id=1303647
35bab9e
rhbz#1346345: https://bugzilla.redhat.com/show_bug.cgi?id=1346345
35bab9e
35bab9e
Based on an upstream change by Benjamin Peterson <benjamin@python.org>
35bab9e
- in changeset 101887:d590114c2394 3.4
35bab9e
- https://hg.python.org/cpython/rev/d590114c2394
35bab9e
---
35bab9e
 Lib/smtplib.py | 5 +++++
35bab9e
 1 file changed, 5 insertions(+)
35bab9e
35bab9e
diff --git a/Lib/smtplib.py b/Lib/smtplib.py
35bab9e
index 4756973..dfbf5f9 100755
35bab9e
--- a/Lib/smtplib.py
35bab9e
+++ b/Lib/smtplib.py
35bab9e
@@ -773,6 +773,11 @@ class SMTP:
35bab9e
             self.ehlo_resp = None
35bab9e
             self.esmtp_features = {}
35bab9e
             self.does_esmtp = 0
35bab9e
+        else:
35bab9e
+            # RFC 3207:
35bab9e
+            # 501 Syntax error (no parameters allowed)
35bab9e
+            # 454 TLS not available due to temporary reason
35bab9e
+            raise SMTPResponseException(resp, reply)
35bab9e
         return (resp, reply)
35bab9e
 
35bab9e
     def sendmail(self, from_addr, to_addrs, msg, mail_options=[],
35bab9e
-- 
35bab9e
2.5.5
35bab9e