]> git.decadent.org.uk Git - dak.git/commitdiff
Do not consider MD5-based signatures valid
authorAnsgar Burchardt <ansgar@debian.org>
Sat, 16 Jan 2016 14:48:11 +0000 (15:48 +0100)
committerAnsgar Burchardt <ansgar@debian.org>
Sat, 16 Jan 2016 15:18:46 +0000 (16:18 +0100)
daklib/gpg.py
tests/fixtures/gpg/md5.asc [new file with mode: 0644]
tests/test_gpg.py

index 6968635ddbe33807d8557e4cf3eeab8ad45a9e50..94842083125a5633a27c8dd58e6014568f9c1b9f 100644 (file)
@@ -196,6 +196,11 @@ class SignedFile(object):
         #             <expire-timestamp> <sig-version> <reserved> <pubkey-algo>
         #             <hash-algo> <sig-class> <primary-key-fpr>
         if fields[1] == "VALIDSIG":
+            # GnuPG accepted MD5 as a hash algorithm until gnupg 1.4.20,
+            # which Debian 8 does not yet include.  We want to make sure
+            # to not accept uploads covered by a MD5-based signature.
+            if fields[9] == "1":
+                raise GpgException("Digest algorithm MD5 is not trusted.")
             self.valid = True
             self.fingerprints.append(fields[2])
             self.primary_fingerprints.append(fields[11])
diff --git a/tests/fixtures/gpg/md5.asc b/tests/fixtures/gpg/md5.asc
new file mode 100644 (file)
index 0000000..accf639
--- /dev/null
@@ -0,0 +1,13 @@
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: MD5
+
+Message generated with 'gpg2 --digest-algo=md5 --clearsign'
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v2
+
+iJwEAQEBAAYFAlaP2k4ACgkQy51cWChgboRBWAQAqMnBlLPbOrTHY6uJUIf2/qBI
+Bqj9GspTdOyalwnRYY0NC7WTAvhgNig2/xsqHoj0zqYyINNu2ocsMUEWfmO20JAa
+3b1I1BifEGJbrr8Y7WVO80HCcrKmFi18cqRzdgD2e7zwR3Dvf8PEZFcLPIAKy6JY
+nKbgHVdvcVXLr9mj61o=
+=5qF0
+-----END PGP SIGNATURE-----
index 7c0519688ef61dcb2cd4a4f2c84bf8321d1f6d41..e7ec86af07f137265363af96f40b2e82cf414b76 100755 (executable)
@@ -69,5 +69,9 @@ class GpgTest(DakTestCase):
         with self.assertRaises(GpgException):
             verify('gpg/plaintext.txt')
 
+    def test_md5_assertion(self):
+        with self.assertRaises(GpgException):
+            verify('gpg/md5.asc')
+
 if __name__ == '__main__':
     unittest.main()