Commit a9eefe7
committed
openpgp/packet: reject too-short decrypted session key
EncryptedKey.Decrypt reads the decrypted session key as b[0] (cipher),
b[1:len(b)-2] (key) and b[len(b)-2:] (checksum) without a length check.
A crafted public-key-encrypted message whose RSA, ElGamal or ECDH
ciphertext decrypts to fewer than three octets makes these index and
slice operations panic (index out of range / slice bounds out of
range). This is reachable from ReadMessage when decrypting an
attacker-supplied message, a denial of service for programs that
decrypt untrusted OpenPGP messages.
Reject len(b) < 3 with a StructuralError before indexing.1 parent 5f2de1a commit a9eefe7
1 file changed
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
97 | 105 | | |
98 | 106 | | |
99 | 107 | | |
| |||
0 commit comments