What changed, and why it matters
This update fixes how the Monero GUI reads OpenPGP public keys. Previously, the software might have accepted a revoked (cancelled) subkey, or used an older signature that allowed signing even when a newer one did not. The patch now rejects revoked subkeys and picks the most recent binding signature. This prevents an attacker who controls an old or revoked OpenPGP subkey from tricking the wallet into treating it as valid for signing.
Treat this as a security hardening fix and include it in the next release. Users building from source or applying patches should update to a revision containing this commit. No immediate emergency response is indicated, but downstream packagers should backport the change because it corrects certificate validation logic.
Security signals we found
OpenPGP subkey revocation not previously enforced
Binding signature selection did not consider creation time, allowing stale signing-capable signatures to override newer non-signing ones
Marker/Trust packets now skipped without terminating subkey signature sequence
Patch is defensive hardening of cryptographic certificate validation
Evidence from the diff
The patch refactors subkey signature parsing in src/openpgp/openpgp.cpp. It introduces a read_subkey_signature helper that records signature type, creation time, and whether key flags permit signing. The public_key_block parser now tracks the current subkey, collects all following signature packets, detects subkey revocation signatures (0x28), and selects the newest subkey binding signature (0x18) by creation-time subpacket. It ignores Marker (10) and Trust (12) packets without ending the subkey, and finalizes subkey acceptance only when the newest binding signature allows signing and the subkey is not revoked. serialization.h adds marker and trust packet tag constants.
Changed components
src/openpgp/openpgp.cppsrc/openpgp/serialization.hMonero GUI OpenPGP public-key import / verification pathInspect captured patch +74 / −20
### src/openpgp/openpgp.cpp
@@ -49,6 +49,8 @@ namespace
{
constexpr const uint8_t signature_type_subkey_binding = 0x18;
+constexpr const uint8_t signature_type_subkey_revocation = 0x28;
+constexpr const uint8_t subpacket_type_creation_time = 2;
constexpr const uint8_t subpacket_type_key_flags = 27;
constexpr const uint8_t key_flag_sign_data = 0x02;
@@ -276,16 +278,27 @@ public_key_rsa read_public_key(const std::vector<uint8_t> &data)
gcry_mpi_get_nbits(public_key_n.get()));
}
-bool subkey_binding_allows_signing(const std::vector<uint8_t> &data)
+struct subkey_signature
+{
+ uint8_t type;
+ uint32_t creation_time;
+ bool allows_signing;
+};
+
+// Returns false for signature versions other than 4
+bool read_subkey_signature(const std::vector<uint8_t> &data, subkey_signature &result)
{
deserializer<epee::span<const uint8_t>> signature(epee::to_span(data));
- if (signature.read_big_endian<uint8_t>() != 4 ||
- signature.read_big_endian<uint8_t>() != signature_type_subkey_binding)
+ if (signature.read_big_endian<uint8_t>() != 4)
{
return false;
}
+ result.type = signature.read_big_endian<uint8_t>();
+ result.creation_time = 0;
+ result.allows_signing = false;
+
/* const auto algorithm = */ signature.read_big_endian<uint8_t>();
/* const auto hash_algorithm = */ signature.read_big_endian<uint8_t>();
@@ -300,14 +313,18 @@ bool subkey_binding_allows_signing(const std::vector<uint8_t> &data)
}
const uint8_t type = subpackets.read_big_endian<uint8_t>() & 0x7f;
- const epee::span<const uint8_t> subpacket = subpackets.read_span(length - 1);
- if (type == subpacket_type_key_flags)
+ deserializer<epee::span<const uint8_t>> subpacket(subpackets.read_span(length - 1));
+ if (type == subpacket_type_creation_time)
+ {
+ result.creation_time = subpacket.read_big_endian<uint32_t>();
+ }
+ else if (type == subpacket_type_key_flags)
{
- return subpacket.size() > 0 && (subpacket[0] & key_flag_sign_data) != 0;
+ result.allows_signing = !subpacket.empty() && (subpacket.read_big_endian<uint8_t>() & key_flag_sign_data) != 0;
}
}
- return false;
+ return true;
}
} // namespace
@@ -362,38 +379,73 @@ public_key_block::public_key_block(const epee::span<const uint8_t> buffer)
}
m_user_id.assign(data->begin(), data->end());
- // Only use subkeys allowed to sign
+ // Only use non-revoked subkeys whose most recent binding signature allows signing.
+ // A subkey's signatures are all the signature packets following it, up to the next packet that is not a
+ // signature, Marker or Trust packet.
bool primary_key_found = false;
const std::vector<uint8_t> *subkey = nullptr;
- packets.for_each([this, &primary_key_found, &subkey](packet_tag::type type, const std::vector<uint8_t> &packet) {
+ bool subkey_revoked = false;
+ bool subkey_binding_found = false;
+ subkey_signature subkey_binding{};
+
+ const auto finish_subkey = [&]() {
+ if (subkey != nullptr && !subkey_revoked && subkey_binding_found && subkey_binding.allows_signing &&
+ is_rsa_public_key(*subkey))
+ {
+ push_back(read_public_key(*subkey));
+ }
+ subkey = nullptr;
+ subkey_revoked = false;
+ subkey_binding_found = false;
+ };
+
+ packets.for_each([&](packet_tag::type type, const std::vector<uint8_t> &packet) {
switch (type)
{
+ case packet_tag::type::signature:
+ if (subkey != nullptr)
+ {
+ subkey_signature signature;
+ if (!read_subkey_signature(packet, signature))
+ {
+ break;
+ }
+ if (signature.type == signature_type_subkey_revocation)
+ {
+ subkey_revoked = true;
+ }
+ else if (
+ signature.type == signature_type_subkey_binding &&
+ (!subkey_binding_found || signature.creation_time >= subkey_binding.creation_time))
+ {
+ subkey_binding = signature;
+ subkey_binding_found = true;
+ }
+ }
+ break;
+ // Marker and Trust packets carry no certificate data and must be ignored without ending the subkey
+ case packet_tag::type::marker:
+ case packet_tag::type::trust:
+ break;
case packet_tag::type::public_key:
+ finish_subkey();
if (primary_key_found)
{
throw std::runtime_error("multiple public keys");
}
push_back(read_public_key(packet));
primary_key_found = true;
- subkey = nullptr;
break;
case packet_tag::type::public_subkey:
+ finish_subkey();
subkey = &packet;
break;
- case packet_tag::type::signature:
- if (subkey != nullptr)
- {
- if (is_rsa_public_key(*subkey) && subkey_binding_allows_signing(packet))
- {
- push_back(read_public_key(*subkey));
- }
- subkey = nullptr;
- }
- break;
default:
+ finish_subkey();
break;
}
});
+ finish_subkey();
if (!primary_key_found)
{
### src/openpgp/serialization.h
@@ -53,6 +53,8 @@ struct packet_tag
{
signature = 2,
public_key = 6,
+ marker = 10,
+ trust = 12,
user_id = 13,
public_subkey = 14,
};Why this scored 72/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.