fix(transaction): make Verify recover-and-compare, fail-closed#15
Open
ety001 wants to merge 1 commit into
Open
fix(transaction): make Verify recover-and-compare, fail-closed#15ety001 wants to merge 1 commit into
ety001 wants to merge 1 commit into
Conversation
SignedTransaction.Verify iterated over an empty slice instead of tx.Signatures, so the verification loop body never executed and the method unconditionally returned (true, nil) for any input — including transactions with no signatures, garbage signatures, or signatures over a tampered digest. Rewrite Verify to recover each signer's public key from the compact (recoverable) signature via ecdsa.RecoverCompact and compare it to the expected pubkey. This matches the codebase's existing verified path (wif.PublicKey.VerifySha256). Sign() emits compact signatures, so the previous DER-based ecdsa.ParseSignature approach in the audit fix suggestion could never have worked even with correct iteration. Verify is now fail-closed: empty signatures, pubkey/signature count mismatch, malformed hex, bad compact-signature format, recovery failure, and key mismatch all return (false, non-nil error). Add TestTransaction_VerifyNegativeCases covering tampered digest, empty signatures, wrong pubkey, and malformed signature, plus a baseline sanity check. Refs: steem-audit/projects/steemutil/audit-reports/2026-07-code-scan.md (finding [中])
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
Fixes the [中] signature verification bypass finding in
steem-audit/projects/steemutil/audit-reports/2026-07-code-scan.md.SignedTransaction.Verifybuilt an empty slice and iterated over that instead oftx.Signatures, so the loop body never ran and the method returned(true, nil)for any input — no signatures, garbage signatures, signatures over a tampered digest, all passed.Fix
Rewrite as recover-and-compare: recover each signer's pubkey from the compact signature via
ecdsa.RecoverCompactand compare to the expected key. This is the same verified mechanism already used inwif.PublicKey.VerifySha256.Verify is now fail-closed: empty sigs, count mismatch, malformed hex, bad compact format, recovery failure, key mismatch →
(false, error).Test
TestTransaction_SignAndVerifystill passes (positive path).TestTransaction_VerifyNegativeCases: tampered digest, empty signatures, wrong pubkey, malformed signature (all returnfalse), plus a baseline sanity check.Refs: steem-audit/projects/steemutil/audit-reports/2026-07-code-scan.md