{"record":{"id":"6c964ea6ecbfd4f3","repo":"jdx/mise","slug":"the-stamp-list-from-host-for-project-has-seque","errorCode":null,"errorMessage":"the stamp list from {host} for {project} has sequence {sequence}, below the {last} already accepted; refusing what may be a rollback","messagePattern":"the stamp list from (.+?) for (.+?) has sequence (.+?), below the (.+?) already accepted; refusing what may be a rollback","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/packslip_stamps.rs","lineNumber":259,"sourceCode":"        bail!(\n            \"{host} published a stamp list for {project} before (sequence {last}) but now answers 404 at {url}; refusing to treat that as no list, since it would drop the yanks that list carried\"\n        );\n    }\n    Ok(())\n}\n\nfn check_sequence_in(\n    dir: &Path,\n    host: &str,\n    project: &str,\n    list: &ReleaseListStatement,\n) -> Result<()> {\n    let mut state = read_state(dir, host)?;\n    let sequence = list.predicate.sequence;\n    if let Some(&last) = state.sequences.get(project)\n        && sequence < last\n    {\n        bail!(\n            \"the stamp list from {host} for {project} has sequence {sequence}, below the {last} already accepted; refusing what may be a rollback\"\n        );\n    }\n    if state.sequences.get(project) != Some(&sequence) {\n        state.sequences.insert(project.to_string(), sequence);\n        write_state(dir, host, &state)?;\n    }\n    Ok(())\n}\n\n/// Fetch and verify every trusted host's list for a project. `None` when\n/// no stampers are configured or the tool trusts its vendor alone. A host\n/// that has no list for the project stamps nothing; one whose list fails\n/// to verify is an error, since silently ignoring it would let a broken\n/// host widen what another admits.\npub(crate) async fn fetch(project: &str, opts: &ToolVersionOptions) -> Result<Option<Stamps>> {\n    if trusts_vendor(opts) {\n        return Ok(None);","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/packslip_stamps.rs#L241-L277","documentation":"Raised by packslip_stamps::check_sequence_in when a freshly fetched stamp list has a sequence number lower than the highest sequence already accepted from that host for the project. This is rollback protection: an attacker (or a compromised/regressed mirror) replaying an old list could re-advertise yanked releases, so mise rejects any sequence below the recorded one.","triggerScenarios":"Calling check_sequence during a stamp-list fetch/refresh when state.sequences[project] exists and list.predicate.sequence < last — i.e. the signed list carries an older sequence number than what this machine already accepted from that host.","commonSituations":"A compromised or rolled-back mirror serving an old signed list; the publisher accidentally re-signing with a lower sequence; restoring old server-side state; switching between hosts/CDNs that have divergent sequence counters (though this check is per-host).","solutions":["Obtain a stamp list with the current (>= last accepted) sequence from the host — ask the publisher to publish/resign with a higher sequence.","Refresh from the canonical host URL rather than a stale mirror or cache.","If the rollback is legitimate (deliberate publisher decision), explicitly clear the local per-host sequence state after verifying with the publisher, then re-accept.","Investigate possible compromise — a lower sequence from the same host is a classic replay/rollback attack signature."],"exampleFix":"// server-side before: resigned list with sequence 5 after clients accepted 7\n// after: publish with sequence 8\n// (client-side: re-fetch from the canonical URL once the list is republished)","handlingStrategy":"retry","validationCode":"// compare fetched sequence against locally accepted before applying\nconst state = readHostState(dir, host);\nconst last = state.sequences?.[project];\nif (last !== undefined && list.predicate.sequence < last) {\n  throw new Error(`rollback detected from ${host}: ${list.predicate.sequence} < ${last}`);\n}","typeGuard":"function isMonotonic(list, acceptedSequence) {\n  return acceptedSequence === undefined || list.predicate.sequence >= acceptedSequence;\n}","tryCatchPattern":"try {\n  applyStampList(host, project, list);\n} catch (e) {\n  if (String(e).includes(\"below the\") && String(e).includes(\"rollback\")) {\n    // treat as a security signal: re-fetch from the canonical host, investigate the mirror\n    refetchFromCanonical(host, project);\n  } else throw e;\n}","preventionTips":["Always fetch stamp lists from the canonical host URL, not cached or mirrored copies that may lag.","Treat any sequence-rollback error as a potential supply-chain incident and investigate before clearing state.","Have publishers increase (never decrease) sequence numbers when republishing lists."],"tags":["packslip","rollback","sequence-number","supply-chain-security"],"backgroundTag":"invalid-state-transition","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}