openpgp/packet: reject an exportable-certification subpacket with no body - #328
Open
elimisteve wants to merge 1 commit into
Open
elimisteve wants to merge 1 commit into
elimisteve wants to merge 1 commit into
Conversation
…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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #327.
parseSignatureSubpacketindexedsubpacket[0]in theexportableCertSubpacketcase 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 withindex out of range [0] with length 0, reachable throughopenpgp.ReadKeyRingandopenpgp/v2.ReadKeyRingon untrusted input.This returns a
StructuralErrorfor any length other than 1, matching the other fixed-length subpackets. I went through the rest of thatswitch; 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.ReadKeyRingand expects aStructuralError; on main it panics.