Fix/low serializer hardening - #2
Open
lordbutterfly-hive wants to merge 37 commits into
Open
Conversation
This reverts commit 184a0e5.
calling api from alternate node
* feat: chain id config * cleanup: redundant if statements * hf26 nai serialization * rpc client: return specific error message
…t instead of silent corruption
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
appendVAssetsilently truncated sub-precision decimals → now returns an error.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 withnilerror).KeyPairFromWifdidn't length-check the decoded key (a wrong-length WIF derived a different key) → now rejectslen != 32.AddSigappended without dedup → now skips duplicates (a duplicated sig is rejected by Hive).appendVStringArraytruncated the 1-byte count at 256 (256 →0x00) → now errors whenlen > 255;CustomJsonOperation.SerializeOpsurfaces it.RequestIdwasint;uint32(negative)wrapped silently → field is nowuint32.DEPLOYMENT — ATOMIC with go-vsc-node (REQID)
HG-L-REQIDchangesRequestId int → uint32. go-vsc-node assignsRequestId: requestId(int) atlib/hive/hive.go:169and:177→ it will not compile against this hivego until those sites castuint32(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-dependentTestRoundRobinPriority(hits api.hive.blog), unrelated.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(+ newaudit_c6_low_test.go). No binaries. Nogo.mod/go.sumchange.