Skip to content

Reject CRLF and embedded newlines across C2SP parsers and signers - #292

Merged
mhutchinson merged 1 commit into
transparency-dev:mainfrom
mhutchinson:reject-crlf
Nov 3, 2026
Merged

mhutchinson merged 1 commit into
transparency-dev:mainfrom
mhutchinson:reject-crlf

Conversation

@mhutchinson

Copy link
Copy Markdown
Contributor

C2SP specs (tlog-proof@v1, tlog-checkpoint, signed-note, tlog-cosignature, and tlog-policy) require strict LF (\n) line endings and forbid carriage returns (\r) in text bodies, origins, and single-line base64 fields.

Previously:

  • bufio.Scanner with bufio.ScanLines in proof.TLogProof.Unmarshal and witness.Policy.Unmarshal silently stripped \r before \n.
  • encoding/base64.StdEncoding.DecodeString silently ignores \r and \n, allowing \r on the checkpoint root hash line in log.Checkpoint.Unmarshal and note.formatRFC6962STH, as well as \r or \n in single-line vkey, skey, and note.Signature.Base64 strings.
  • note.formatEd25519CosignatureV1 and note.formatMLDSACosignatureV1 did not reject \r (or \r/\n in subtree origin and cosigner name).

Reject \r across proof.TLogProof.Unmarshal, log.Checkpoint.Unmarshal, witness.Policy.Unmarshal, note.formatEd25519CosignatureV1, and note.formatRFC6962STH; reject \r and \n in note key/signature decoders and note.formatMLDSACosignatureV1; and add test coverage across all affected entry points.

C2SP specs (tlog-proof@v1, tlog-checkpoint, signed-note, tlog-cosignature, and tlog-policy) require strict LF (\n) line endings and forbid carriage returns (\r) in text bodies, origins, and single-line base64 fields.

Previously:
- bufio.Scanner with bufio.ScanLines in proof.TLogProof.Unmarshal and witness.Policy.Unmarshal silently stripped \r before \n.
- encoding/base64.StdEncoding.DecodeString silently ignores \r and \n, allowing \r on the checkpoint root hash line in log.Checkpoint.Unmarshal and note.formatRFC6962STH, as well as \r or \n in single-line vkey, skey, and note.Signature.Base64 strings.
- note.formatEd25519CosignatureV1 and note.formatMLDSACosignatureV1 did not reject \r (or \r/\n in subtree origin and cosigner name).

Reject \r across proof.TLogProof.Unmarshal, log.Checkpoint.Unmarshal, witness.Policy.Unmarshal, note.formatEd25519CosignatureV1, and note.formatRFC6962STH; reject \r and \n in note key/signature decoders and note.formatMLDSACosignatureV1; and add test coverage across all affected entry points.
@mhutchinson
mhutchinson requested a review from a team as a code owner November 3, 2026 15:57
@mhutchinson
mhutchinson requested a review from phbnf November 3, 2026 15:57
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.39%. Comparing base (fa00c16) to head (c93e451).
⚠️ Report is 201 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #292      +/-   ##
==========================================
+ Coverage   82.57%   89.39%   +6.82%     
==========================================
  Files           5       10       +5     
  Lines         241     1047     +806     
==========================================
+ Hits          199      936     +737     
- Misses         30      111      +81     
+ Partials       12        0      -12     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mhutchinson
mhutchinson merged commit 3d94fca into transparency-dev:main Nov 3, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants