Checkpoint.Unmarshal accepts non-canonical base64 roots; C2SP now requires rejecting them

Open Beginner friendly
#285 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go
Domain
security

Research direction

Read log/checkpoint.go around line 68 and check how base64.StdEncoding.DecodeString handles non-canonical root encodings. The issue proposes strict decoding and optionally re-encoding for exact line canonicality; compare that behavior against the C2SP requirement cited in the report. Done means non-canonical roots are rejected while canonical checkpoints still parse.

Written by the indexing model from the issue text.

Description

log/checkpoint.go line 68 decodes the root line with base64.StdEncoding.DecodeString.
Go's default decoder ignores non-zero trailing bits, so ...Kjg= and ...Kjh= both
decode to the same 32 bytes and both parse as the same checkpoint.

As of C2SP/C2SP#370 (merged 2026-10-01, closing C2SP/C2SP#348) tlog-checkpoint and
signed-note say: "Encoders MUST generate canonical base64 according to RFC 4648,
Section 3.5, and decoders MUST reject non-canonical encodings."

Measured 2026-09-21 over the tlog-witness add-checkpoint interface against
transparency-dev/witness @55a5a0b: it cosigned both spellings of one root at size 25.
The two notes are byte-different, each carries a valid log signature, and each now carries
a witness cosignature. A log can collect a quorum across the two forms; a monitor keyed on
checkpoint bytes sees two checkpoints for one tree state. Reproduction:
https://github.com/MarkovianProtocol/witness-gauntlet (case "non-canonical base64 root").

Fix is one call: base64.StdEncoding.Strict().DecodeString(...), which rejects non-zero
trailing bits (missing padding is already an error in StdEncoding). Go's decoder still
skips CR and LF even in strict mode, so a re-encode-and-compare closes that last gap if you
want the line to be exactly one spelling. Happy to send the PR if you'd rather not.

Markovian Protocol

Dominant language
Go
Stars
14
Forks
13
Avg merge
2d 7h
Merged PRs (30d)
10

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.