Verification

May 10, 2026 ยท View on GitHub

This document describes client-side verification in the Hex ecosystem.

Overview

Clients MUST verify integrity before trusting registry data or package contents.

See Client Flows for the authoritative specification.

Registry Verification

All clients perform these steps:

Verification Steps

StepActionFailure Behavior
1. DecompressDecompress gzip-compressed registry fileError
2. DecodeParse outer Signed protobufError
3. Verify signatureRSA-PKCS1-SHA512 against hex.pm public keyABORT
4. Verify repositoryCheck repository field matches expectedABORT
5. Parse payloadParse inner protobuf (Names, Versions, Package)Error

Important

Steps 3 and 4 are security-critical. Failure at these steps indicates possible tampering or cross-repository attacks.

Signature Verification Detail

flowchart TD
    A[Fetch registry file] --> B[Decompress gzip]
    B --> C[Parse Signed protobuf]
    C --> D{Verify RSA-PKCS1-SHA512<br/>signature}
    D -->|Valid| E[Parse inner payload]
    D -->|Invalid| F[ABORT - tampering detected]
    E --> G{Repository field<br/>matches?}
    G -->|Yes| H[Trust data]
    G -->|No| I[ABORT - cross-repo attack]

Tarball Verification

Verification Steps

StepActionFailure Behavior
1. DownloadFetch from /tarballs/{name}-{version}.tarRetry/error
2. Compute checksumSHA-256 of entire tarballError
3. CompareCheck against outer_checksum from signed registryABORT
4. ExtractExtract: VERSION, metadata.config, contents.tar.gz, CHECKSUMError
5. Inner checksumVerify CHECKSUM file (optional, legacy)Warning

Checksum Verification Detail

flowchart TD
    A[Download tarball] --> B[Compute SHA-256]
    B --> C{Matches outer_checksum<br/>from registry?}
    C -->|Yes| D[Extract contents]
    C -->|No| E[ABORT - tampering detected]
    D --> F{Check inner<br/>CHECKSUM?}
    F -->|Yes| G{Inner checksum<br/>valid?}
    F -->|No| H[Continue - outer is authoritative]
    G -->|Yes| H
    G -->|No| I[Warn - possible issue]

Client Implementations

ClientLibraryLanguage
Mix (Elixir)hex_coreErlang
Rebar3 (Erlang)hex_coreErlang
Gleamhexpm-rustRust

Verification Code Locations

ClientVerification ModuleNotes
hex_corehex_repoShared by Mix and Rebar3
hexpm-rusthexpm::repoUses ring crate for crypto

Error Handling

Signature Failure

ResponseAction
AbortStop immediately
MessageSecurity error - possible tampering
FallbackNEVER fall back to unverified data

Checksum Mismatch

ResponseAction
AbortStop immediately
MessageIntegrity error - possible tampering
FallbackNEVER use mismatched artifact

Network Failure

ResponseAction
RetryAttempt retry with backoff
CacheMay fall back to cached data (with warning)
ReasonCached data was verified when fetched

Mirror Security

Trusted vs Untrusted Mirrors

Mirror TypeCredentialsUse Case
TrustedCan receive credentialsOrganization-controlled mirrors
UntrustedNEVER send credentialsCommunity mirrors, public caches

Untrusted Mirror Security

Caution

When using untrusted mirrors:

  • NEVER send credentials (API keys, tokens)
  • ALWAYS verify signatures (signatures are from hex.pm, not mirror)
  • Private packages MUST use trusted endpoints only
flowchart TD
    A[Client] --> B{Mirror type?}
    B -->|Trusted| C[Send credentials OK]
    B -->|Untrusted| D[NO credentials]
    C --> E[Fetch data]
    D --> E
    E --> F[Verify signature<br/>against hex.pm key]
    F -->|Valid| G[Use data]
    F -->|Invalid| H[Reject]

Public Key

Current Key

AttributeValue
AlgorithmRSA
Key size2048 bits
UsageRSA-PKCS1-SHA512 signatures
DistributionHardcoded in clients
Availabilityhttps://hex.pm/docs/public_keys

Key Pinning

Tip

For high-security environments, verify the public key out-of-band before first use. Compare the key in your client library against the key published at hex.pm.

Future: Attestation Verification

Planned verification capabilities for SLSA provenance and other attestations:

FeatureDescriptionStatus
SLSA provenanceVerify build attestationsPlanned
VEX verificationVerify vulnerability statementsPlanned
Transparency proofsVerify inclusion in transparency logPlanned
Policy enforcementRequire minimum provenance levelPlanned