Skip to content

Unexpected parsing result when reading a key block that includes some unparsable key packets #1420

@larabr

Description

@larabr

With the default config.ignoreUnsupportedPackets = true, we potentially parse a sequence of keys incorrectly.
For example, given the following sequence of packets:

v4 key packet
user id
v4 signature
...
v3 key packet
user id
v3 signature

we would mistakenly interpret the second User ID as belonging to the v4 key, instead of the v3 one, as the v3 packets will be ignored on parsing (due to their unsupported version).
A similar problem can occur with config.ignoreMalformedPackets = true (it's false by default), if any non-leading key packet in the sequence fails to parse.

This behaviour should not lead to security issues, since the User ID (or signatures/subkeys) won't be considered valid by the preceding key (in fact, the certification signatures won't verify). However, this parsing result is unexpected and should be fixed. This is an edge case scenario that should only happen in the context of multiple keys.

To fix the issue, one option is to create an UnparsablePacket object whenever we fail to parse a packet. Such packet should contain the original packet tag and the raw packet content. Then, readKeys could properly process the resulting packet list and discard all packets following an UnparsablePacket, until a new key packet is encountered.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions