[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#849698: jessie-pu: package python-crypto/2.6.1-5+deb8u1



Hi

On 2017-01-03 11:05:40, Sebastian Ramacher wrote:
> On 2017-01-01 20:55:40, Sebastian Ramacher wrote:
> > Control: tags -1 - moreinfo
> > 
> > Hi
> > 
> > On 2016-12-31 17:03:32, Adam D. Barratt wrote:
> > > Control: tags -1 + moreinfo
> > > 
> > > On Thu, 2016-12-29 at 23:15 +0100, Sebastian Ramacher wrote:
> > > > I'd like to fix CVE-2013-7459 (#849495) in jessie via the next point release.
> > > > The issue was marked as no-dsa.
> > > > 
> > > > The proposed debdiff is attached. The same patch was applied to the package in
> > > > unstable.
> > > 
> > > +  * Throw exception when IV is used with ECB or CTR (CVE-2013-7459)
> > > 
> > > Do we know if any packages currently in Debian misuse the functions in
> > > that way? (I realise that any that do are broken, but I'd prefer to find
> > > that out /before/ releasing an point release that makes them explode if
> > > possible.)
> 
> Seems like python-paramiko broke in wheezy-lts (#850025). I will come back to
> you once I've checked if stable is affected as well.

New debdiff is attached. Instead of throwing an exception the IV is simply
ignored and a warning is displayed.

Cheers
-- 
Sebastian Ramacher
diff --git a/debian/changelog b/debian/changelog
index ecee2bf..57a5a16 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+python-crypto (2.6.1-5+deb8u1) jessie; urgency=high
+
+  * debian/patches/CVE-2013-7459.patch: Raise a warning when IV is used with
+    ECB or CTR and ignored the IV in that case. Thanks to Salvatore Bonaccorso
+    for the initial patch. (CVE-2013-7459) (Closes:
+    #849495)
+
+ -- Sebastian Ramacher <sramacher@debian.org>  Tue, 03 Jan 2017 13:56:09 +0100
+
 python-crypto (2.6.1-5) unstable; urgency=medium
 
   * debian/patches/asn1-decoding.patch: Fix TypeError in ASN1 implementation.
diff --git a/debian/patches/CVE-2013-7459.patch b/debian/patches/CVE-2013-7459.patch
new file mode 100644
index 0000000..cb9d982
--- /dev/null
+++ b/debian/patches/CVE-2013-7459.patch
@@ -0,0 +1,86 @@
+From 8dbe0dc3eea5c689d4f76b37b93fe216cf1f00d4 Mon Sep 17 00:00:00 2001
+From: Legrandin <helderijs@gmail.com>
+Date: Sun, 22 Dec 2013 22:24:46 +0100
+Subject: [PATCH] Throw exception when IV is used with ECB or CTR
+
+The IV parameter is currently ignored when initializing
+a cipher in ECB or CTR mode.
+
+For CTR mode, it is confusing: it takes some time to see
+that a different parameter is needed (the counter).
+
+For ECB mode, it is outright dangerous.
+
+This patch forces an exception to be raised.
+
+[sramacher@debian.org]: Raise a warning instead of an exception and ignore IV.
+---
+ lib/Crypto/SelfTest/Cipher/common.py | 31 +++++++++++++++++++++++--------
+ src/block_template.c                 | 11 +++++++++++
+ 2 files changed, 34 insertions(+), 8 deletions(-)
+
+--- a/lib/Crypto/SelfTest/Cipher/common.py
++++ b/lib/Crypto/SelfTest/Cipher/common.py
+@@ -239,19 +239,34 @@
+         return """%s .decrypt() output of .encrypt() should not be garbled""" % (self.module_name,)
+ 
+     def runTest(self):
+-        for mode in (self.module.MODE_ECB, self.module.MODE_CBC, self.module.MODE_CFB, self.module.MODE_OFB, self.module.MODE_OPENPGP):
++
++        ## ECB mode
++        mode = self.module.MODE_ECB
++        encryption_cipher = self.module.new(a2b_hex(self.key), mode)
++        ciphertext = encryption_cipher.encrypt(self.plaintext)
++        decryption_cipher = self.module.new(a2b_hex(self.key), mode)
++        decrypted_plaintext = decryption_cipher.decrypt(ciphertext)
++        self.assertEqual(self.plaintext, decrypted_plaintext)
++
++        ## OPENPGP mode
++        mode = self.module.MODE_OPENPGP
++        encryption_cipher = self.module.new(a2b_hex(self.key), mode, self.iv)
++        eiv_ciphertext = encryption_cipher.encrypt(self.plaintext)
++        eiv = eiv_ciphertext[:self.module.block_size+2]
++        ciphertext = eiv_ciphertext[self.module.block_size+2:]
++        decryption_cipher = self.module.new(a2b_hex(self.key), mode, eiv)
++        decrypted_plaintext = decryption_cipher.decrypt(ciphertext)
++        self.assertEqual(self.plaintext, decrypted_plaintext)
++
++        ## All other non-AEAD modes (but CTR)
++        for mode in (self.module.MODE_CBC, self.module.MODE_CFB, self.module.MODE_OFB):
+             encryption_cipher = self.module.new(a2b_hex(self.key), mode, self.iv)
+             ciphertext = encryption_cipher.encrypt(self.plaintext)
+-            
+-            if mode != self.module.MODE_OPENPGP:
+-                decryption_cipher = self.module.new(a2b_hex(self.key), mode, self.iv)
+-            else:
+-                eiv = ciphertext[:self.module.block_size+2]
+-                ciphertext = ciphertext[self.module.block_size+2:]
+-                decryption_cipher = self.module.new(a2b_hex(self.key), mode, eiv)
++            decryption_cipher = self.module.new(a2b_hex(self.key), mode, self.iv)
+             decrypted_plaintext = decryption_cipher.decrypt(ciphertext)
+             self.assertEqual(self.plaintext, decrypted_plaintext)
+ 
++
+ class PGPTest(unittest.TestCase):
+     def __init__(self, module, params):
+         unittest.TestCase.__init__(self)
+--- a/src/block_template.c
++++ b/src/block_template.c
+@@ -170,6 +170,17 @@
+ 				"Key cannot be the null string");
+ 		return NULL;
+ 	}
++	if (IVlen != 0 && mode == MODE_ECB)
++	{
++		PyErr_WarnEx(PyExc_FutureWarning, "ECB mode does not use IV", 1);
++		IVlen = 0;
++	}
++	if (IVlen != 0 && mode == MODE_CTR)
++	{
++		PyErr_WarnEx(PyExc_FutureWarning,
++			"CTR mode needs counter parameter, not IV", 1);
++		IVlen = 0;
++	}
+ 	if (IVlen != BLOCK_SIZE && mode != MODE_ECB && mode != MODE_CTR)
+ 	{
+ 		PyErr_Format(PyExc_ValueError,
diff --git a/debian/patches/series b/debian/patches/series
index e077da9..191ab43 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -9,3 +9,4 @@ multiprocessing-test.patch
 unittest-stream.patch
 deprecated-test-methods.patch
 asn1-decoding.patch
+CVE-2013-7459.patch

Attachment: signature.asc
Description: PGP signature


Reply to: