Mask five-byte CSV operands before narrowing - #24
Open
adrienlacombe wants to merge 1 commit into
Open
adrienlacombe wants to merge 1 commit into
adrienlacombe wants to merge 1 commit into
Conversation
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.
OP_CHECKSEQUENCEVERIFYaccepts up to five-byte nonnegative ScriptNums. An operand such as2^32has no relevant BIP68 bits and should compare like zero, but the interpreter attempted to convert the entirei64tou32withexpect, causing a panic. Mask the operand to the type flag and low 16 bits before narrowing, matching Bitcoin Core'sCheckSequencecomparison.Eight regression groups exercise this rule in legacy, SegWit v0 and Tapscript contexts, as well as height/time mismatches, transaction version, input/operand disable bits, negative, overlong and nonminimal encodings. A targeted test reproduced the panic before this patch;
cargo test --locked --workspace --all-featurespasses all 20 tests after it. Upstream does not track Cargo.lock; the local run used an ignored lockfile generated offline.The rule follows BIP112 and Bitcoin Core v30.3. This patch is based directly on upstream master and is independent of other pending interpreter PRs.
The funded follow-up in solving-bitcoin/bitcoin-scripts#241 confirms all 19 complete Core transactions and 19 local consensus/policy comparisons, with byte-identical reports from two fresh nodes. The lab uses a combined interpreter pin that retains the other pending repairs; this standalone patch remains based directly on upstream master.