Skip to content

Fix: stop trimming trailing bytes from binary S4 identity files - #7

Merged
danielpclark merged 2 commits into
mainfrom
fix/s4-binary-trailing-bytes
Oct 21, 2026
Merged

danielpclark merged 2 commits into
mainfrom
fix/s4-binary-trailing-bytes

Conversation

@danielpclark

Copy link
Copy Markdown
Owner

What

SQRL::S4Identity.parse trimmed ASCII whitespace from both ends of its input before reading the header. The binary sqrldata form ends with a random AES-GCM tag, so about one file in forty ended in a byte that counts as whitespace (0x09–0x0D, 0x20) and came back one byte short:

block of type 2 claims 73 bytes but only 72 remain

Only leading whitespace is skipped now; the SQRLDATA text form keeps its tolerant trimming (base64url ignores whitespace anyway).

Why

This is the cause of the intermittent failures in the sqrl-client identity and CLI specs seen on the CI runs for #6 (Ruby 3.3 and 3.4 jobs on one run, green on the next) and once locally: any spec that writes a freshly created or re-keyed identity file and reads it back hit it whenever the tag's last byte was whitespace.

Verification

  • New regression specs: a binary file ending in \n round-trips byte for byte, with and without leading whitespace; the text form still tolerates surrounding whitespace. The first spec fails on the old parser with the exact CI error and passes on the fix.
  • sqrl-core 240 examples and sqrl-client 66 examples green; RuboCop clean.
  • A 60-iteration stress run of the CLI sequence (create, export, change-password, re-key, list previous) that reproduced the failure in 1 of 25 runs before the fix now passes 60 of 60.

Changelog

sqrl-core CHANGELOG gains an Unreleased entry; this warrants a 0.1.2 patch release of sqrl-core (the other gems are unaffected but move in lockstep).


Generated by Claude Code

danielpclark and others added 2 commits October 21, 2026 05:04
S4Identity.parse trimmed ASCII whitespace from both ends of its input
before reading the header. The binary form ends with a random AES-GCM
tag, so about one file in forty ended in a byte that counts as
whitespace and came back one byte short ("block of type 2 claims 73
bytes but only 72 remain"), which is what made the client identity
specs fail intermittently in CI. Only leading whitespace is skipped
now; the SQRLDATA text form keeps its tolerant trimming. Adds
regression specs for both forms.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LquamEUPHNaNMzZW6tZz8r
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LquamEUPHNaNMzZW6tZz8r
@semanticdiff-com

Copy link
Copy Markdown

Review changes with  SemanticDiff

@danielpclark
danielpclark merged commit 986eb05 into main Oct 21, 2026
18 checks passed
@danielpclark danielpclark mentioned this pull request Oct 21, 2026
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