Study guides · Intermediate

Trust boundaries in signed software updates

Use a local signature example and update history to separate trusted keys, freshness, target integrity, and installation failure.

Ask Logeia about this articleTry the three questionsReview your answers

Updated

On this page
  1. A valid signature is only one acceptance condition
  2. Trust in the key needs an independent basis
  3. Verify changed bytes and a different key with a standard API
  4. Judge an old authentic release separately
  5. Assign a reason to every history row
  6. Key rotation must connect to existing trust
  7. Verification can succeed while installation fails
  8. Define the offline and clock assumptions
  9. Exercise: separate signature validity from adoption
  10. Ask Logeia about this articleCheck your understanding

A valid signature is only one acceptance condition

A software updater must consider more than whether downloaded bytes changed. It must decide whose authority permits installation, which version is acceptable, and how long metadata remains valid. A successful signature still leaves questions about why its verification key is trusted, whether the release is old, and whether freshness requirements hold. The label “signed” does not specify an acceptance policy.

Use a fictional local artifact to separate what a signature API verifies from what an update protocol decides. Read the threat-model and hash/MAC lessons first, including the difference between shared-key MACs and public-key signatures. Nothing here distributes an update or replaces a real application. Version numbers and times in the worked history are fixed explanatory values, not a status report about a currently published product.

Trust in the key needs an independent basis

Blindly trusting a public key delivered alongside an artifact does not handle replacement of artifact, signature, and key together. A verifier needs an independent basis, such as initially trusted metadata or a key transition authorized by existing trust. Signature verification establishes a relation to the supplied key. Whether that key has authority to approve updates is a separate decision.

The Update Framework separates responsibilities into roles including root, targets, snapshot, and timestamp. Such separation avoids concentrating all authority in one online key. Thresholds, expiry, delegation, and key-transition procedures must follow the selected specification and implementation. The small program below is not a TUF client implementing those roles. It tests signature computation while explicitly fixing which local key is trusted. Keep that limited purpose visible when interpreting its successful checks.

Verify changed bytes and a different key with a standard API

Save the program as update_signature.py and run python3.12 update_signature.py in a disposable environment with OpenSSL. It generates two RSA key pairs and signs exact JSON bytes containing the digest of a fictional artifact. Changing the signed version field fails verification, as does using the other public key. Restoring the original bytes succeeds again.

All assertions passed with Python 3.12.14 and OpenSSL command-line version 3.0.13. A changed artifact also fails comparison with the digest in the trusted manifest. The signature covers actual bytes, including JSON ordering and whitespace; reformatting semantically equivalent JSON need not preserve a signature over those bytes. This is a minimal API example, not a recreation of TUF signature representations or canonicalization rules. Production update metadata should follow the chosen protocol and implementation.

python
import hashlib
import json
import subprocess
import tempfile
from pathlib import Path

def openssl(*args):
    return subprocess.run(['openssl', *args], capture_output=True, text=True)

with tempfile.TemporaryDirectory(prefix='lavacs-update-') as directory:
    root = Path(directory)
    def p(name): return str(root / name)
    for name in ['release', 'other']:
        assert openssl('genpkey', '-algorithm', 'RSA', '-pkeyopt', 'rsa_keygen_bits:2048', '-out', p(name + '.key')).returncode == 0
        assert openssl('pkey', '-in', p(name + '.key'), '-pubout', '-out', p(name + '.pub')).returncode == 0
    artifact = b'fictional application version eight\n'
    manifest = {'name': 'app.bin', 'version': 8, 'expires': '2026-10-29T00:00:00Z', 'sha256': hashlib.sha256(artifact).hexdigest()}
    original = json.dumps(manifest, sort_keys=True, separators=(',', ':')).encode()
    (root / 'release.json').write_bytes(original)
    assert openssl('dgst', '-sha256', '-sign', p('release.key'), '-out', p('release.sig'), p('release.json')).returncode == 0
    def signature_valid(public_key):
        return openssl('dgst', '-sha256', '-verify', p(public_key), '-signature', p('release.sig'), p('release.json')).returncode == 0
    assert signature_valid('release.pub')
    assert not signature_valid('other.pub')
    (root / 'release.json').write_bytes(original.replace(b'"version":8', b'"version":9'))
    assert not signature_valid('release.pub')
    (root / 'release.json').write_bytes(original)
    assert signature_valid('release.pub')
    assert hashlib.sha256(artifact).hexdigest() == manifest['sha256']
    assert hashlib.sha256(artifact + b'changed').hexdigest() != manifest['sha256']
    print(openssl('version').stdout.strip())
    print('original accepted; wrong key and changed signed bytes rejected')
    print('trusted manifest digest matches original artifact, not changed artifact')

Judge an old authentic release separately

Fix an illustrative device state that has trusted version seven and starts an update on 28 October 2026. An authorized version eight with metadata expiring the next day may proceed after the remaining checks. An authorized version six can still have a valid signature, yet is older than the recorded state. Its rejection concerns rollback policy, not necessarily byte modification.

Now imagine being shown authentic version-seven information indefinitely. A peer's statement alone cannot distinguish an absence of new releases from suppression of newer information. Expiring metadata provides a condition for detecting a freeze, subject to clock and trusted-state assumptions. Reading a version from a filename, or merely resetting a retrieval timestamp, does not maintain authenticated update history. The protocol must connect signed information to persisted client state.

Assign a reason to every history row

Compare original version eight, a changed artifact, a different key, old version six, and expired version-eight metadata. A changed artifact fails the digest from trusted metadata. A different key lacks the required authority. Old and expired metadata can pass signature computation while failing version and freshness policy.

This table is an exercise in distinguishing conditions, not permission to replace TUF verification with an abbreviated custom acceptance routine. A real implementation also checks that multiple metadata documents describe a consistent update state and that lengths and hashes match. Identify each failed boundary before compressing role authorization and target verification into a single Boolean outcome. That makes both implementation review and operational errors more interpretable without changing the protocol's prescribed checks.

CaseDecision beyond signature computationOutcome
Version 8, unexpiredCheck existing trust and version policyProceed to remaining checks
Changed artifactTrusted digest does not matchReject
Different keyNo authorized update authorityReject
Reissued version 6Older than recorded version 7Reject
Expired metadataNot valid at fixed update start timeReject

Key rotation must connect to existing trust

Attaching a new key to the next artifact is not enough to authorize rotation. Define which existing authority approves the transition and under which conditions the new authority becomes active. TUF root updates have version and signature rules for moving from trusted state to the next state. Implementations must verify the required ordering and thresholds.

A lost key and a compromised key can leave different recovery options. Design recovery in advance and decide how online signing responsibilities differ from more strongly protected authority. The fixture regenerates temporary keys each run and implements none of that operation. A product update design must consider initial trust distribution, rotation, expiry, and recovery together. Calling a signature function correctly is a necessary local behavior, not the completion criterion for the update system.

Verification can succeed while installation fails

After artifact verification, installation can still fail through writes, insufficient space, incompatible configuration, or unsuccessful migration. Treat verification and application as separate stages. Do not persist a partially applied state as a completed update. Overwriting the existing executable before validation can destroy the working version even when the proposed update is subsequently rejected.

Staging, switching, startup checks, and recovery depend on the packaging and deployment environment. Authorized operational recovery to an older running environment is not the same as unconditionally accepting old metadata supplied by a peer. Define recovery authority and trusted-state handling explicitly. A successful signature log does not prove that a user's device booted a healthy updated version. Installation completion and operational health require their own evidence beyond artifact authenticity.

Define the offline and clock assumptions

For devices that remain offline, define what continues running and which update state is reported after metadata expires. An improvised expiry bypass may remove the condition intended to detect a freeze. Clock errors or loss of persisted trust must not be recorded as successful updates. Follow the chosen mechanism's recovery procedure and distinguish accepting new update material from continuing to run an already installed version.

Exercise: separate signature validity from adoption

Should a device that has recorded version seven accept an authentic version six? Under the illustrative no-rollback policy, it should reject it. Then explain expired version-eight metadata separately: signature computation can remain valid while the freshness condition fails. A signature's relation between bytes and key does not automatically satisfy an expiry rule.

Finally ask whether trusting other.pub would make artifacts from any signer safe. It would not; the verifier's chosen authority has changed. Write the reasoning in terms of initial trust, signature, version, expiry, target match, and applied state. Mark which parts were executed through APIs and which were explained as protocol or operational requirements. This keeps the successful local experiment from being expanded into an unsupported assurance about an entire update system.

Reading and practice are recorded separately in this browser, for each language.

Learn this in order

Understand the systems behind the web · STEP 19

Choose a learning path