Skip to content

Multisig: Invalid signatures cause (possibly) wrong verification result #3872

Closed

Description

@dmnks

Early testing of the multi-signature feature (done by @Jakuje and the team) has revealed some possible issues/bugs related the overall verification result when one or more signature is faulty, namely:

  1. Corrupted signatures (inverted byte in the middle of the signature area) currently do not cause the whole verification to fail if there is another signature that is OK
  2. Signatures done by algorithms forbidden in crypto-policies currently do cause the whole verification to fail, even if there is another signature that is OK

It seems like these two cases should actually result in the exact opposites, i.e. the former (a corrupt signature) should result in a negative verification whereas the latter (a forbidden or disabled algo) should result in a positive one. This is especially true in the context of the original requirements captured in #3385, which says:

verification will:

  • ignore unknown algorithms
  • require all known (and enabled) signatures to pass for a positive verification

Related: #3363, #3385

Activity

  1. Jakuje commented on Aug 5, 2025

    @Jakuje
    Contributor

    Checking how we go around the corrupted signatures, it looks like partially rpm-sequoia fault. I think we are getting the error from here:

    https://github.com/rpm-software-management/rpm-sequoia/blob/cd090b02119565c6d171fa9a892790c966cf10ef/src/lib.rs#L943

    which explodes inside of OpenSSL:

    _pgpVerifySignature2: -> error: Failure: error:0200008A:rsa routines:RSA_padding_check_PKCS1_type_1:invalid padding:crypto/rsa/rsa_pk1.c:79:, error:02000072:rsa routines:rsa_ossl_public_decrypt:padding check failed:crypto/rsa/rsa_ossl.c:796:, error:1C880004:Provider routines:rsa_verify_directly:RSA lib:providers/implementations/signature/rsa_sig.c:1133:, error:030000EA:digital envelope routines:EVP_PKEY_verify:provider signature failure:crypto/evp/signature.c:1183:RSA verify:
    

    where the current cryptographic backend does not really provide any lints nor hints to the calling function/application how to handle this particular error. I think the first thing to fix would be rpm-sequoia reporting some more information through the lints:

    rpm-software-management/rpm-sequoia#98

    But it would not fix the issue (maybe make it just more verbose) as the rpm continues checking the next signatures and then hides the failure with the following code:

    rpm/lib/rpmvs.cc

    Lines 581 to 585 in 4537a6a

    if (sinfo->rc == RPMRC_FAIL) {
    const struct rpmsinfo_s * alt = getAlt(sis, sinfo);
    if (alt && alt->rc == RPMRC_OK)
    sinfo->rc = RPMRC_NOTFOUND;
    }

    583		    if (alt && alt->rc == RPMRC_OK)
    (gdb) 
    584			sinfo->rc = RPMRC_NOTFOUND;
    

    I am not sure here what is the alternative here though as I only see the sequoia being invoked twice (once for each signature). Does it mean "there is at least one other RPMv6 signature that verified ok", ignore any failure of other RPM signatures?

  2. pmatilai commented on Aug 5, 2025

    @pmatilai
    Member

    It's been a while, but there aren't supposed to be any alternatives in the signature land, that's only for payload digests and their ALT versions. But that code predates multiple signatures by many years so maybe it trips up in an unexpected way someplace. The code around this is pretty fishy anyway.

  3. pmatilai commented on Aug 5, 2025

    @pmatilai
    Member

    Looking at getAlt() and its surroundings, it seems getAlt() should be looking at sinfo->alt instead of sinfo->id for matching. And, none of this should get invoked for signatures at all.

  4. added theissue type on Aug 5, 2025
  5. added this to the 6.0.0 beta2 milestone on Aug 5, 2025
  6. Jakuje commented on Aug 5, 2025

    @Jakuje
    Contributor

    I went ahead to test the signatures that are not allowed by crypto policies. This makes rpm-sequoia to return RPMRC_NOTTRUSTED, which makes the verification of the whole RPM fail. This is in comparison with the generic error RPMRC_FAIL returned in case of corrupted signature.

    This is the second part of question, if this behavior is expected or not.

    The third option what can happen is that one of the keys is not imported, where we got from rpm-sequoia the RPMRC_NOKEY and which is likely ok to fail the whole verification as it would open an attack vector of not importing the key (or somehow blocking) the key the attacker can not break and leaving the verification only on the one that could be broken.

    Actually, the last option (untested by Standa yet) would be the unknown algorithm. That is something I can try with the fedora rawhide stock rpm-sequoia (without PQC support) and PQC signature on RPM. This is now behaving the same way as the case of malformed signature:

     pgp_verify_signature: Checking signature b91c created at Tue Aug  5 08:25:16 2025 using SHA512 with E926E88BF36FB8BDE503BF48C231FC3A413D7AF44897F3FEC1EB4DE547A16DB5 / 318C3716254627D597FA882432C4AE1D4E2BEEE1DFEE755E46D21742DD65AED8
    _pgpVerifySignature2: Lints: Verifying a signature using certificate E926E88BF36FB8BDE503BF48C231FC3A413D7AF44897F3FEC1EB4DE547A16DB5 (MLDSA-SIGN):
      1. Certificate E926E88BF36FB8BD invalid: policy violation
          because: No binding signature at time 2025-08-05T08:25:16Z
      2. Certificate E926E88BF36FB8BD invalid: policy violation
          because: No binding signature at time 2025-08-05T13:59:35Z
    _pgpVerifySignature2: -> error: Failure: No binding signature at time 2025-08-05T08:25:16Z
    error: Verifying a signature using certificate E926E88BF36FB8BDE503BF48C231FC3A413D7AF44897F3FEC1EB4DE547A16DB5 (MLDSA-SIGN):
      1. Certificate E926E88BF36FB8BD invalid: policy violation
          because: No binding signature at time 2025-08-05T08:25:16Z
      2. Certificate E926E88BF36FB8BD invalid: policy violation
          because: No binding signature at time 2025-08-05T13:59:35Z
    

    The logs are a bit more verbose, but sequoia is unable to understand this algorithm so from what I see, it returns the generic error which is being hidden in RPM (I believe by the same code path as in the previous case).

    Any thoughts what should happen at these cases?

  7. added a commit that references this issue on Aug 6, 2025
    73bc2fd
  8. pmatilai commented on Aug 6, 2025

    @pmatilai
    Member

    I think pmatilai@73bc2fd should address the issue of invalid signature passing because of the alt mechnism, but I don't yet have a reproducer here.

  9. pmatilai commented on Aug 6, 2025

    @pmatilai
    Member

    As for the NOKEY and NOTTRUSTED special flakes:
    NOTTRUSTED is needed to keep installed packages with expired signatures accessible - whether through actual date passing, crypto-policy update or such. Similar story for NOKEY.

    In the context of 'rpmkeys -K' with enforcing signature policy (eg the way dnf calls it), the result must be a failure if anything returns non-OK.

  10. Jakuje commented on Aug 6, 2025

    @Jakuje
    Contributor

    I think pmatilai@73bc2fd should address the issue of invalid signature passing because of the alt mechnism, but I don't yet have a reproducer here.

    Thanks! What would be the best way to provide a reproducer? Get a test hello.rpm with one malformed signatured? I can provide that and open a PR.

  11. pmatilai commented on Aug 6, 2025

    @pmatilai
    Member

    A new binary rpm is ok as long as it's small. Fuzzing existing stuff in the test-suite is kinda preferrable, if easily doable (I realize it often is not)

  12. added a commit that references this issue on Aug 6, 2025
    2cc874e
  13. Jakuje commented on Aug 6, 2025

    @Jakuje
    Contributor

    Did open a #3880 with the test and your change. Locally seems to work for me (while fails without the patch).

  14. added a commit that references this issue on Aug 7, 2025
    5489273
  15. added a commit that references this issue on Aug 7, 2025
    d409205
  16. moved this from Backlog to Done in RPMon Aug 7, 2025
  17. added a commit that references this issue on Jan 20, 2026
    51885f9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    SECURITYbugcryptoSignatures, keys, hashes and their verification

    Type

    Projects

    • Status
      Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions