Skip to content

Fix eight findings in registry verification with root keys - #286

Merged
ericmj merged 10 commits into
mainfrom
registry-verification-fixes
Dec 4, 2026
Merged

ericmj merged 10 commits into
mainfrom
registry-verification-fixes

Conversation

@ericmj

@ericmj ericmj commented Dec 3, 2026

Copy link
Copy Markdown
Member

Eight fixes to the registry verification with root keys, one per commit. None of this code is in a hex_core release.

  • A Hex user who upgrades to a release that raises min_version after an intermediate key was revoked kept the registry files cached under that key, because stored lists below min_version counted as absent and revoked was false. Their keys now count for revoked.
  • A list that nobody signed returned key_list_rollback or key_list_conflict, because update_key_lists/3 compared versions first. The root signatures are checked first and the list returns untrusted_key_list.
  • A later intermediate key list that left out a revoked root key, or listed it as usable, made a client trust the key again. A client with stored lists rejects such a list, also when its stored list is below min_version. Only configured root keys count.
  • A freshness entry with any expiry below 2^63 was accepted, so one signature with a far expiry kept its payload accepted until the freshness key was revoked. An entry more than 60 days ahead doesn't count. The intermediate key list had no limit and can now expire at most 400 days ahead.
  • hex_repo passed a server-sent x-hex-payload-hash through on a 304.
  • Keys are compared by their bytes, and a compressed-point encoding of a key counted as another key: two signers from one private key, and a revocation that didn't match. A P-256 or P-384 key is accepted as DER with a named curve and the uncompressed point only, and an intermediate key list is rejected when a root key that names an ECDSA algorithm isn't in that encoding.
  • A client configured with a single public key raised on a resource without an RSA signature, without a payload, or one that can't be decoded. It returns {error, bad_signature}.
  • The limit of 16 signature entries was checked after the protobuf decode, so a 16 KB response with 16 MiB of empty entries made the client build about 8 million terms before it rejected the message. The entries are counted on the encoded bytes first, and a key list file is at most 64 KiB uncompressed, because its payload is decoded before its signatures are verified. Fixes a 16 KB response makes the client allocate about 900 MB before it verifies anything #281.

The specification change is hexpm/specifications#106.

ericmj added 10 commits December 4, 2026 00:37
update_key_lists/3 treated stored lists below `min_version` as absent, so
`revoked` was always `false` for them. A client release that raises
`min_version` after an intermediate key is revoked then kept the registry
files cached under that key.

The keys of those stored lists now count for `revoked`. The lists still
don't count for the rollback checks.
update_key_lists/3 compared versions before it checked the root signatures
of the fetched intermediate key list, so a list that nobody signed
returned `key_list_rollback` or `key_list_conflict`. It returns
`untrusted_key_list`.
A later intermediate key list that left out a revoked root key, or listed
it as usable, made a client trust the key again. A client with stored lists
now rejects such a list. The stored list counts for this also when it is
below `min_version`. Only root keys that the client is configured with
count.
…pire

check_freshness/4 accepted any expiry below 2^63, so one freshness
signature with a far expiry kept its payload accepted until the freshness
key was revoked. An entry that expires more than 60 days from now doesn't
count, which is the longest a signing key list can be valid.

The intermediate key list had no limit. It can expire at most 400 days
from now.
hex_repo removed a `x-hex-payload-hash` header that the repository sends
from a `200` only, so a caller that reads the header from a `304` got the
server's value.
Keys are compared by their bytes, and a compressed-point encoding of a key
counted as another key: two signers from one private key, and a revocation
that didn't match the configured key. A key is accepted as DER with a named
curve and the uncompressed point only, and an intermediate key list is
rejected when a root key that names an ECDSA algorithm isn't in that
encoding.
The single public key path raised on a `Signed` message without
`signature` and on one that can't be decoded. Both return
`{error, bad_signature}`.
The limit of 16 signature entries was checked after the protobuf decode,
so 16 MiB of empty entries, 16 KB compressed, made the decoder build
millions of terms before the message was rejected. The entries are counted
on the encoded message first.

The payload of a key list is decoded before its signatures are verified,
so a key list file is at most 64 KiB uncompressed.

Fixes #281
@ericmj
ericmj force-pushed the registry-verification-fixes branch from 672e438 to 9f3178f Compare December 3, 2026 23:38
@ericmj
ericmj merged commit acb27b4 into main Dec 4, 2026
10 checks passed
@ericmj
ericmj deleted the registry-verification-fixes branch December 4, 2026 10:08
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.

a 16 KB response makes the client allocate about 900 MB before it verifies anything

1 participant