← Back to Pull requests

fix(blob): compare file checksums case-insensitively #5036

Closed
unknown closed this pull request without merging on Aug 05, 2026 23:34 UTC
View on GitHub
unknown unknown commented on Aug 02, 2026 09:48 UTC
Author

Summary

cosign initialize --root-checksum rejects a correct checksum when it is written in upper case.

hex.EncodeToString always emits lower case, and pkg/blob/load.go:107 compares it to the user-supplied value with !=. Hex is case-insensitive, and plenty of sources publish digests in upper case, so a user holding a perfectly good checksum is told it is wrong.

Reproducer against the real sigstore root:

$ curl -sO https://tuf-repo-cdn.sigstore.dev/12.root.json
$ shasum -a 256 12.root.json | awk '{print toupper($1)}'
5FE1E509A47277183A004745942C0A116379297DA9F1CCA529774320F1A5DFAB

$ cosign initialize --root 12.root.json \
    --root-checksum 5FE1E509A47277183A004745942C0A116379297DA9F1CCA529774320F1A5DFAB
Error: incorrect checksum for file 12.root.json: expected 5FE1E509A47277183A004745942C0A116379297DA9F1CCA529774320F1A5DFAB but got 5fe1e509a47277183a004745942c0a116379297da9f1cca529774320f1a5dfab

The error message gives it away: expected and got are the same digest.

Why this is more than cosmetic

LoadFileOrURLWithChecksum has exactly one caller, cmd/cosign/cli/initialize/init.go:59, and that is the TUF root of trust. So the person who hits this is doing the right thing: pinning a root they fetched out of band. What the tool tells them is that the root does not match. The nearest way out is --force-skip-checksum-validation, which is exactly the habit this flag exists to prevent.

Change

strings.EqualFold instead of !=. Wrong checksums stay wrong: a DEADBEEF-prefixed digest is still rejected, and the prefixed forms (sha256:, sha512:) behave the same as before apart from case.

Testing

Added upper-case sha256 and sha512 cases to the existing TestLoadURLWithChecksum. They fail on main and pass with the fix; the existing cases are untouched. go vet ./pkg/blob/, gofmt and go build ./... are clean.

Also ran both binaries end to end against sigstore's 12.root.json:

| build | checksum | exit |
|---|---|---|
| main | lower case | 0 |
| main | UPPER CASE | 1 |
| fix | UPPER CASE | 0, initialization completes |
| fix | sha256: + UPPER CASE | 0 |
| fix | DEADBEEF... | 1, still rejected |

Release Note

cosign initialize --root-checksum now accepts upper-case and mixed-case hex digests.

Documentation

NA

Diff: 289 lines (+216 / -73) across 3 files Reviewer: semx Review duration: 5146m
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 289 lines diff across 3 files
0.40
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.339
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #5036"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 39.8% (MEDIUM) · Higher = larger blast radius
39.8%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 15.7% · Safe to merge
15.7%