Skip to content

Fix/low serializer hardening - #2

Open
lordbutterfly-hive wants to merge 37 commits into
DeathwingTheBoss:mainfrom
vsc-eco:fix/low-serializer-hardening
Open

Fix/low serializer hardening#2
lordbutterfly-hive wants to merge 37 commits into
DeathwingTheBoss:mainfrom
vsc-eco:fix/low-serializer-hardening

Conversation

@lordbutterfly-hive

@lordbutterfly-hive lordbutterfly-hive commented Jun 4, 2026

Copy link
Copy Markdown

Summary

Six low-severity hardening fixes to the L1 (Hive) serialization/signing library, from the Magi mainnet pre-liquidity audit + the follow-up audit-of-fixes. Each replaces silent corruption / a missing guard with an explicit error. Valid inputs serialize byte-for-byte identically — no change to any currently-valid signed transaction.

What & why

Finding Fix
HG-L-DECTRUNC appendVAsset silently truncated sub-precision decimals → now returns an error.
AF-1 (audit-of-fixes) TransferOperation / TransferToSavings / TransferFromSavings .SerializeOp() were discarding that new error → now check and return it (they were the last 3 callers; previously a sub-precision amount produced a malformed signed tx with nil error).
HG-L-WIFLEN KeyPairFromWif didn't length-check the decoded key (a wrong-length WIF derived a different key) → now rejects len != 32.
HG-L-ADDSIG AddSig appended without dedup → now skips duplicates (a duplicated sig is rejected by Hive).
HG-L-VSTR255 appendVStringArray truncated the 1-byte count at 256 (256 → 0x00) → now errors when len > 255; CustomJsonOperation.SerializeOp surfaces it.
HG-L-REQID RequestId was int; uint32(negative) wrapped silently → field is now uint32.

DEPLOYMENT — ATOMIC with go-vsc-node (REQID)

HG-L-REQID changes RequestId int → uint32. go-vsc-node assigns RequestId: requestId (int) at lib/hive/hive.go:169 and :177it will not compile against this hivego until those sites cast uint32(requestId).
Sequence: merge this PR → cut a tag (e.g. v0.0.x) → in go-vsc-node's PR, go get github.com/vsc-eco/hivego@<tag> + add the cast, in the same commit. Do not merge the go-vsc-node PR before this tag exists.

Testing

  • go build ./... clean; full suite 49 pass / 1 fail — the 1 fail is the pre-existing network-dependent TestRoundRobinPriority (hits api.hive.blog), unrelated.
  • New regression tests in audit_c6_low_test.go: every fix is proven to fail without the change and pass with it; byte-identity asserted for valid inputs.

Files

serializer.go, broadcaster.go, keys.go, hive_ops.go, serializer_test.go (+ new audit_c6_low_test.go). No binaries. No go.mod/go.sum change.

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.

7 participants