SecurityInnovation / PGPy

Pretty Good Privacy for Python
BSD 3-Clause "New" or "Revised" License
320 stars 98 forks source link

Invalid key self-signature is not rejected #336

Open mgorny opened 4 years ago

mgorny commented 4 years ago

e.gpg.gz (I'm sorry, I had to gzip it so that github accepted it)

The attached key file has a bad self-signature. GnuPG rejects the key as invalid:

$ gpg --import e.gpg
gpg: key D26247C45DCEDCA4: 1 bad signature
gpg: key D26247C45DCEDCA4: no valid user IDs
gpg: this may be caused by a missing self-signature
gpg: Total number processed: 1
gpg:           w/o user IDs: 1

However, PGPy behaves as if everything were fine:

In [1]: import pgpy

In [2]: k = pgpy.PGPKey.from_file('e.gpg')[0]

In [3]: k.expires_at
Out[3]: datetime.datetime(2024, 8, 12, 19, 9, 57)

Even if I were to assume that I need to manually verify self-signatures (the docs don't say a word about that), the self_signatures attribute is empty.

mgorny commented 4 years ago

Ping.

mgorny commented 4 years ago

Ok, I think I know how to handle this. I was being stupid and missed the point that signatures are part of userids. So if I take userids, and verify them, I get the verification failure properly.