Skip to content

OpenPGPCertificate cannot bind a key whose user ID is not valid UTF-8 #2583

Backlog

Description

@aloubyansky

RFC 9580 §5.11 says a user ID is "intended to be" UTF-8 but doesn't require it. Some artifacts on Maven Central appear to be signed with keys that carry Latin-1 user IDs, such as gson's C7BE5BCC9FEC15518CFDA882B0F3710FA64900E7. Their self-certifications are made over the user ID's raw bytes, and GnuPG 2.4 and Sequoia 1.4 verify signatures made with them.

OpenPGPCertificate cannot bind such a key:

  • PGPPublicKey.getUserIDs() skips a user ID that doesn't decode as UTF-8 (the "Skip non-UTF8 user-ids" catch in getUserIDs()).
  • OpenPGPPrimaryKey builds its identity components from getUserIDs(), so the user ID never becomes an OpenPGPUserId.
  • Even if it did, OpenPGPUserId holds a String. Its certifications are looked up with getSignaturesForID(String) and checked with verifyCertification(String, PGPPublicKey), both of which re-encode as UTF-8, so they can't match the raw bytes.

Without a direct-key signature, the primary key is then unbound and the certificate has no signing key, although the certification is valid.

Reproducer (jbang NonUtf8UserIdRepro.java): a v4 RSA key whose only user ID is "Éamonn eamonn@example.org" in ISO-8859-1, positively certified over those bytes. It prints:

certification verifies over the raw bytes: true
raw user IDs: 1
getUserIDs(): 0
OpenPGPCertificate user IDs: 0
primary key bound: false
signing keys: 0

Expected behavior: the user ID is a component of the certificate, its certification is checked over its raw bytes, and the primary key is bound.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions