Chrono Mock
LanguageEnglish
Documentation Checking what you downloaded

The window

Scenarios and calendars

Checking what you downloaded

Every release from 0.2.0 on carries checksums, a bill of materials with an attestation, and a signature on every program the project builds. Three checks, from the quickest to the most thorough.

What a release carries

  • SHA256SUMS: the SHA-256 hash of every package and bill of materials on the release page.
  • A bill of materials for each package (*.spdx.json, SPDX 2.3): every component from elsewhere inside it, with its version and licence.
  • An attestation of that bill of materials (*.sigstore.json), signed by GitHub's infrastructure.
  • A signature on every program the project builds, chrono_hook.dll included, and on the installer. Each carries a timestamp, which keeps the signature valid after the certificate expires.

Version 0.1.0 has none of this. It came out before all of it, and none of it can be added to a release afterwards.

The checksum

In PowerShell, in the folder the package and SHA256SUMS were downloaded to:

(Get-FileHash ChronoMock-cli-win.zip).Hash -in ((Get-Content SHA256SUMS) -split '\s+')
True

True means the file is, byte for byte, one the release published. False means it is not, so download it again. For another package, change the name. This check catches a download that broke on the way. It cannot catch a release page someone replaced, because SHA256SUMS comes from the same page. The two checks below can.

The signature

Unzip the package and ask Windows about chrono_hook.dll, the library Chrono Mock loads into other programs and so the file most worth checking. In the command-line package it is chrono-cli\chrono_hook.dll, in the window package ChronoMock\core\x64\chrono_hook.dll:

$s = Get-AuthenticodeSignature chrono-cli\chrono_hook.dll
$s.Status
Valid
$s.SignerCertificate.GetCertHashString('SHA256')
47B79AD3CFA53EF846CAD03A59148F8C981D0B1196891E48B8C8D7982B10C148
$null -ne $s.TimeStamperCertificate
True
  • Valid: the file has not changed since it was signed, and Windows trusts the certificate.
  • The fingerprint names the certificate itself: 47B79AD3CFA53EF846CAD03A59148F8C981D0B1196891E48B8C8D7982B10C148. The repository pins it in packaging/codesign.json, and every file the project signs is checked against it when a release comes out. A renewed certificate has a new fingerprint. That file then changes, and the releases signed before keep the fingerprint they were signed with.
  • True on the last line: the signature has a timestamp.

The same works for chrono.exe, for the window's own ChronoMock.exe, and for the installer before you run it: Get-AuthenticodeSignature ChronoMock-app-win-x64.msi. The rest of the window package is signed by Microsoft or by nobody, as it came from its makers, and SECURITY.md says which. File Explorer shows the same signature under Properties, Digital Signatures.

The attestation

With the GitHub CLI (gh), in the folder with the package and its .sigstore.json. These are the commands a workflow runs on every release as soon as it is published. They name the window package: for another one, change both names.

gh attestation verify ChronoMock-app-win-x64.zip --repo donislawdev/ChronoMock --predicate-type https://spdx.dev/Document/v2.3
gh attestation verify ChronoMock-app-win-x64.zip --repo donislawdev/ChronoMock --predicate-type https://spdx.dev/Document/v2.3 --bundle ChronoMock-app-win-x64.zip.sigstore.json
cmd /c "gh attestation trusted-root > trusted_root.jsonl"
gh attestation verify ChronoMock-app-win-x64.zip --repo donislawdev/ChronoMock --predicate-type https://spdx.dev/Document/v2.3 --bundle ChronoMock-app-win-x64.zip.sigstore.json --custom-trusted-root trusted_root.jsonl
  • The first asks GitHub for the attestation, so gh has to be signed in to a GitHub account (gh auth login).
  • The second checks the .sigstore.json from the release page instead. It needs no account, but it fetches Sigstore's public keys over the network.
  • The last two need no account, and the last one no network: the third saves those keys to a file once, and the fourth checks with that file. The third goes through cmd because Windows PowerShell 5.1 writes what > redirects as UTF-16, which gh cannot read.

Each ends with code 0 when the package matches its attestation, and with another code when it does not. Leave --predicate-type in: without it, gh looks for a record of a build, which the packages do not have, and says it found no attestation though nothing is wrong.

The attestation says what is inside the package. It does not say a workflow built it: a workflow builds the files, and a person signs them on a machine with a hardware key that cannot be copied. SECURITY.md explains why.