Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better handle invalid parameters to signrawtransaction #9650

Merged
merged 5 commits into from
Feb 6, 2017

Conversation

TheBlueMatt
Copy link
Contributor

Based on #9634.

I remembered why I wrote that to begin with - I was trying to merge signatures from untrusted parties and realized they could cause a DoS by crashing my bitcoind.

This silently skips trying to merge signatures from inputs which
do not exist from transactions provided to signrawtransaction,
instead of hitting an assert.

@TheBlueMatt
Copy link
Contributor Author

Add test cases here for both this PR and #9634. The test fail if either is reverted.

assert_equal(decodedRawTx["vin"][i]["vout"], inp["vout"])

# Make sure decoderawtransaction throws if there is extra data
try:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: The following is usually referred to as `assert_raises(JSONRPCException, self.nodes...

assert 'complete' in rawTxUnsigned
assert_equal(rawTxUnsigned['complete'], False)

# Check that signrawtransaction properly merges unsigned and signed txn, even with garbate in the middle
Copy link
Contributor

@jtimon jtimon Feb 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/garbate/garbage/ ? (if so, same above)

@TheBlueMatt TheBlueMatt force-pushed the 2017-01-better-signraw branch from 9e6b4c1 to ab7b4c7 Compare February 2, 2017 22:32
@TheBlueMatt
Copy link
Contributor Author

Fixed review nits.

@TheBlueMatt TheBlueMatt force-pushed the 2017-01-better-signraw branch from ab7b4c7 to 6dbfe08 Compare February 2, 2017 22:40
@TheBlueMatt
Copy link
Contributor Author

Fixed another "garbage" misspelling....

@laanwj
Copy link
Member

laanwj commented Feb 6, 2017

utACK 6dbfe08 (seems a simple extension of #9634, which I had reviewed before)

@laanwj laanwj merged commit 6dbfe08 into bitcoin:master Feb 6, 2017
laanwj added a commit that referenced this pull request Feb 6, 2017
6dbfe08 [qa] test signrawtransaction merge with missing inputs (Matt Corallo)
ec4f7e4 [qa] Add second input to signrawtransaction test case (Matt Corallo)
691710a [qa] Test that decoderawtransaction throws with extra data appended (Matt Corallo)
922bea9 Better handle invalid parameters to signrawtransaction (Matt Corallo)
7ea0ad5 Fail in DecodeHexTx if there is extra data at the end (Matt Corallo)
@jnewbery
Copy link
Contributor

Apologies - post merge question/comment. The new code in DecodeHexTx adds this check for witness transactions not having junk bytes:

        if (!ssData.empty())
            return false;

12 lines above is a check for non-witness transactions not having junk bytes:

            if (ssData.eof()) {
                return true;

I'm pretty sure that ssData.eof() and ssData.empty() will both be false if there are junk bytes remaining in the CDataStream.

Any reason why you've used a different function call? It's a bit confusing for someone reading the code for the first time.

codablock pushed a commit to codablock/dash that referenced this pull request Feb 7, 2018
…ction

6dbfe08 [qa] test signrawtransaction merge with missing inputs (Matt Corallo)
ec4f7e4 [qa] Add second input to signrawtransaction test case (Matt Corallo)
691710a [qa] Test that decoderawtransaction throws with extra data appended (Matt Corallo)
922bea9 Better handle invalid parameters to signrawtransaction (Matt Corallo)
7ea0ad5 Fail in DecodeHexTx if there is extra data at the end (Matt Corallo)
andvgal pushed a commit to energicryptocurrency/gen2-energi that referenced this pull request Jan 6, 2019
…ction

6dbfe08 [qa] test signrawtransaction merge with missing inputs (Matt Corallo)
ec4f7e4 [qa] Add second input to signrawtransaction test case (Matt Corallo)
691710a [qa] Test that decoderawtransaction throws with extra data appended (Matt Corallo)
922bea9 Better handle invalid parameters to signrawtransaction (Matt Corallo)
7ea0ad5 Fail in DecodeHexTx if there is extra data at the end (Matt Corallo)
CryptoCentric pushed a commit to absolute-community/absolute that referenced this pull request Feb 28, 2019
…ction

6dbfe08 [qa] test signrawtransaction merge with missing inputs (Matt Corallo)
ec4f7e4 [qa] Add second input to signrawtransaction test case (Matt Corallo)
691710a [qa] Test that decoderawtransaction throws with extra data appended (Matt Corallo)
922bea9 Better handle invalid parameters to signrawtransaction (Matt Corallo)
7ea0ad5 Fail in DecodeHexTx if there is extra data at the end (Matt Corallo)
CryptoCentric pushed a commit to absolute-community/absolute that referenced this pull request Mar 2, 2019
…ction

6dbfe08 [qa] test signrawtransaction merge with missing inputs (Matt Corallo)
ec4f7e4 [qa] Add second input to signrawtransaction test case (Matt Corallo)
691710a [qa] Test that decoderawtransaction throws with extra data appended (Matt Corallo)
922bea9 Better handle invalid parameters to signrawtransaction (Matt Corallo)
7ea0ad5 Fail in DecodeHexTx if there is extra data at the end (Matt Corallo)
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants