Skip to content

records: recordText checks the push length again (the check had slipped behind a comment) - #17

Merged
melvincarvalho merged 1 commit into
sidestr:gh-pagesfrom
jjohare:records-push-length
Sep 25, 2026
Merged

melvincarvalho merged 1 commit into
sidestr:gh-pagesfrom
jjohare:records-push-length

Conversation

@jjohare

@jjohare jjohare commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

recordText in siding/lib/records.mjs never checks that a push's declared length matches its data. The check is there, but on the same line as a comment:

if (m[1] && len <= 75) return null; // minimal push only if (m[3].length !== len * 2 || len > 255) return null;

Effect: 6a03 followed by the bytes of tally:x (a 3-byte push, then 4 more bytes after it) reads as the record tally:x. A script that isn't a single push can therefore pass as a tally, an issue or a pool record. It also splits the two readers: sidestr-rs's port of records.mjs checks the length, so a validator on each would read such a transaction differently.

Fix: the check is its own statement again. rules-test.mjs gains one assertion covering bytes after the push, bytes missing, a long push over its length, and a long push of exactly its length (still read).

Verified: the records assertions pass against the patched module (round-trip plus the four new cases). I couldn't run the whole rules-test.mjs here, because it imports blaketestnode from a local checkout path.

If a live chain already has an OP_RETURN whose push length doesn't match its data, this changes how it reads, so it's worth a look before release. sidestr:dreamlab has none, since its records were written by sidestr-rs, which never makes one.

🤖 Generated by Claude Code

…ed behind a comment

'// minimal push only if (m[3].length !== len * 2 || len > 255) return null;'
was one comment, so a record's declared push length was never compared with
its data: 6a03 followed by the bytes of 'tally:x' (a 3-byte push, then bytes
after it) read as the record 'tally:x'. The check is its own statement again;
rules-test covers bytes after the push, bytes missing, and a long push over
its length. sidestr-rs's records port has always checked, so the two readers
now agree.

Co-Authored-By: jjohare <[email protected]>
@melvincarvalho
melvincarvalho merged commit 7d65c54 into sidestr:gh-pages Sep 25, 2026
@melvincarvalho

Copy link
Copy Markdown
Contributor

Merged, thanks. Checked against the live tally chain first: its 36 non-coinbase OP_RETURN records read identically before and after; the 818 other OP_RETURNs are coinbase commitments (a 36-byte push plus the block signature) which the rules never read as records, and which the fixed reader now correctly returns null for. So no live chain changes meaning. rules-test 32/32 on the PR head.

jjohare added a commit to JavaScriptSolidServer/podkey that referenced this pull request Sep 25, 2026
sidestr/spec#17: recordText's length check had slipped behind a comment, so a
script pushing 'tal' with 'ly:x' after the push read as the record 'tally:x'.
Only records.mjs changes in Podkey's vendored set; a test holds the vendored
reader to the fix.
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.

2 participants