Skip to content

Strict-parse the truepic-signature header#37

Merged
jstayton merged 1 commit intodevelopmentfrom
fix/strict-header-parser
May 7, 2026
Merged

Strict-parse the truepic-signature header#37
jstayton merged 1 commit intodevelopmentfrom
fix/strict-header-parser

Conversation

@jstayton
Copy link
Copy Markdown
Collaborator

@jstayton jstayton commented May 7, 2026

Summary

  • Reject headers with anything other than two non-empty comma-separated parts. The previous parser destructured the first two elements and silently dropped anything past the second comma (t=1,s=abc,extra was accepted).
  • Split each k=v pair on the first = only. Base64 signatures can end with = padding, and String.prototype.split('=') followed by 2-element destructuring was silently truncating that padding. It worked in practice because Node's base64 decoder is lenient, but the parser was dropping bytes from its input.
  • Add a regression test for the multi-part comma case.

Test plan

  • npm test — 16/16 pass.
  • npm run lint — clean.

🤖 Generated with Claude Code

- Reject headers with anything other than two non-empty
  comma-separated parts; the previous parser silently dropped
  anything past the second comma.
- Split each `k=v` pair on the *first* `=` only. Base64 signatures
  end with `=` padding, so splitting on every `=` was silently
  truncating the trailing padding from the signature value. Worked
  in practice because Node's base64 decoder is lenient about
  padding, but the parser was dropping bytes from its input.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jstayton jstayton merged commit ba1e294 into development May 7, 2026
4 checks passed
@jstayton jstayton deleted the fix/strict-header-parser branch May 7, 2026 16:57
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.

1 participant