The vulnerability (CVE-2025-30258) in GnuPG before 2.5.5 allows a verification DoS if a user imports a certificate with crafted subkey data (lacking a valid backsig or with incorrect usage flags). The analysis of the patch (commit 48978ccb4e20) reveals the following:
-
get_pubkey_for_sig (g10/getkey.c): This function was primarily responsible for fetching the public key to be used for signature verification. Before the patch, it did not enforce that the key fetched (especially a subkey) must be suitable for signing by setting pk->req_usage = PUBKEY_USAGE_SIG at the outset. This omission allowed it to select subkeys that were not valid for signing, leading to the DoS. The patch directly addresses this by adding this requirement.
-
get_pubkey (g10/getkey.c): This function (whose logic was largely moved to the new get_pubkey_bykid function during refactoring in the same patch) had a flaw in its caching mechanism. As noted in a new comment added by the patch, "The old get_pubkey_function did not check PK->REQ_USAGE when reading form the caceh." This meant that if an unsuitable subkey was cached, get_pubkey could return it without the necessary usage validation, and this key could then be used by get_pubkey_for_sig.
-
check_sig_and_print (g10/mainproc.c): This higher-level function, responsible for checking and displaying signature status, had a procedural vulnerability. When a signature included an embedded key (an "included keyblock"), the function, prior to the patch, relied on the initial verification result. If this initial verification was compromised due to the aforementioned issues in key fetching (i.e., do_check_sig using a malicious subkey from the included block), check_sig_and_print would present a potentially incorrect status. The patch rectifies this by adding a mandatory re-verification step against the main keyring after successfully using an included key.
The functions check_signature (g10/sig-check.c) and do_check_sig (g10/mainproc.c) are also modified in the patch, primarily to propagate a keyblock (r_keyblock) and to call the updated key fetching functions. While they are part of the vulnerable execution path (as they call the functions with the core logic flaws), the actual vulnerabilities (missing checks or flawed procedures) reside in get_pubkey_for_sig, the old get_pubkey's cache handling, and the procedural flaw in check_sig_and_print.