Skip to content

openpgp/packet: reject an exportable-certification subpacket with no body - #328

Open
elimisteve wants to merge 1 commit into
ProtonMail:mainfrom
elimisteve:fix/exportable-cert-subpacket-length
Open

elimisteve wants to merge 1 commit into
ProtonMail:mainfrom
elimisteve:fix/exportable-cert-subpacket-length

Conversation

@elimisteve

Copy link
Copy Markdown

Fixes #327.

parseSignatureSubpacket indexed subpacket[0] in the exportableCertSubpacket case without checking the length, unlike the neighbouring cases. A subpacket whose declared length is 1 is the type octet alone; once the type octet is stripped its body is empty and the index panics with index out of range [0] with length 0, reachable through openpgp.ReadKeyRing and openpgp/v2.ReadKeyRing on untrusted input.

This returns a StructuralError for any length other than 1, matching the other fixed-length subpackets. I went through the rest of that switch; every other case that indexes the body checks its length first, so this was the only one.

The added test feeds the 97-byte key ring from the issue to openpgp/v2.ReadKeyRing and expects a StructuralError; on main it panics.

…body

parseSignatureSubpacket indexed subpacket[0] in the exportableCertSubpacket
case without checking the length, unlike the neighbouring cases. A
subpacket whose declared length is 1 is the type octet alone; once the
type octet is stripped its body is empty and the index panics with
"index out of range [0] with length 0", reachable through
openpgp.ReadKeyRing and openpgp/v2.ReadKeyRing on untrusted input.

Return a StructuralError for any length other than 1, as the other
fixed-length subpackets do.

Fixes ProtonMail#327.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

openpgp: ReadKeyRing panics with index out of range on a malformed exportable-certification subpacket

1 participant