Skip to content

#3359 Classify rejected PGP signatures as bad signatures - #3360

Merged
DenBond7 merged 2 commits into
masterfrom
issue-3359-detect-rejected-signatures
Dec 2, 2026
Merged

DenBond7 merged 2 commits into
masterfrom
issue-3359-detect-rejected-signatures

Conversation

@martgil

@martgil martgil commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

This PR classifies rejected PGP signatures as bad signatures so an invalid signature is not shown as signed.

close #3359


Tests (delete all except exactly one):

  • Tests added or updated

To be filled by reviewers

I have reviewed that this PR... (tick whichever items you personally focused on during this review):

  • addresses the issue it closes (if any)
  • code is readable and understandable
  • is accompanied with tests, or tests are not needed
  • is free of vulnerabilities

@martgil

martgil commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator Author

Hi @DenBond7 @sosnovsky - This one is ready for a review. Thank you!

@DenBond7

DenBond7 commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

This PR's tests only cover tampered content, but #3359 also names expired and revoked signing keys. I checked locally with a throwaway test, using the same processMimeMessage path:

Case master this PR
Key hard-revoked (no reason / compromised) after signing hasBadSignatures = false true
Signature made after the key expired false true
Key soft-revoked (retired/superseded) after signing false false (correct, the signature predates the revocation)

So the fix already handles these cases. Let's pin that with unit tests in ProcessMimeMessageTest: generate a key, sign inline, then revoke or expire the key and verify against the updated cert. Without such tests, a future pgpainless update could start reporting these cases as "Missing verification key", which would quietly turn the red badge into "cannot verify". For a separate PR.

@DenBond7 DenBond7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. The fix closes #3359: every rejected signature except a missing key is now reported as a bad signature, so a tampered message, or one signed with a revoked or expired key, no longer gets the green "signed" badge.

@DenBond7

DenBond7 commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

No androidTest checks PgpBadgeListAdapter.PgpBadge.Type.BAD_SIGNATURE today. The SIGNED badge is covered in MessageDetailsFlowTest, ThreadDetailsGmailApiFlowTest and MessageDetailsSignatureLookupFlowTest, but the red badge is only covered at the VerificationResult level by unit tests. Let's add tampered signed MIME fixtures (cleartext and detached) and check that the message details screen, and the thread view (MessagesInThreadListAdapter) if cheap, show BAD_SIGNATURE. For a separate PR.

@DenBond7

DenBond7 commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

After this PR, any rejection other than "Missing verification key" shows BAD_SIGNATURE. That's the right default, but there is a false-positive case: the stored copy of the sender's key has expired, while the sender has since extended it and published the update. The genuine message now shows "bad signature", and the user can't fix it, because the key lookup (fetchAndUpdateInfoAboutRecipients in MessageDetailsFragment / ThreadDetailsFragment) only runs for hasUnverifiedSignatures.

Proposal (needs agreement on the behaviour first): when the rejection is caused by key validity (expired, revoked), fetch the sender's current key and verify again, showing "verifying" in the meantime. A tampered body still stays red. If the refreshed key is still expired or revoked, keep BAD_SIGNATURE. The refreshed key must go through the usual rules for replacing a stored public key, never a silent swap. For a separate PR.

@DenBond7
DenBond7 merged commit 622d9ea into master Dec 2, 2026
8 checks passed
@DenBond7
DenBond7 deleted the issue-3359-detect-rejected-signatures branch December 2, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve PGP signature verification status handling on Android

2 participants