Skip to content

ngclient: improve rollback protection #1498

Closed
@jku

Description

@jku

I believe ngclient implements the spec as its written... but fails to follow the spirit of the spec in one aspect: as the spec does not explicitly say that expired snapshot and timestamp can be used to do the rollback checks of new snapshot and timestamp (while it does explicitly allow this for root), ngclient does not use expired snapshot and timestamp and instead considers those expired versions invalid. This means a rollback attack (giving the client an older version of the metadata file) is easier as long as the local metadata versions have had time to expire.

Spec (client workflow) could be improved:

  • specify when local cached metadata should be used to maximize the effectiveness of the rollback checks -- currently spec talks about "trusted timestamp" and "trusted snapshot" but never explains how they become trusted or when they're loaded
  • specify when using expired metadata is allowed
    • root: when used to do rollback checks for newer root (this is already in spec)
    • timestamp: when used to do rollback checks for newer timestamp
    • snapshot: when used to do rollback checks for newer snapshot
  • specify when using a snapshot version that does not match the timestamp meta version is allowed: when used to do rollback checks for newer snapshot

I believe it makes sense to work on the ngclient improvements at the same time. I think this should do it:

  • for all of [root, timestamp, snapshot], do all validity checks in TrustedMetadataSet.update_*() as now, except do not check expiry: this allows updating TrustedMetadataSet first with a local (possibly expired) file and then updating with a new downloaded one
  • instead check the expiry when the next top-level type is updated (this is safe because of the strong checks we do: TrustedMetadataSet guarantees that top-level updates can only be done in strict order):
    • when timestamp is updated, first check root expiry
    • when snapshot is updated, first check timestamp expiry
    • when targets is updated, first check snapshot expiry and meta version
  • deprecate root_update_finished() as the expiry check is now done consistently as described above

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions