Skip to content

Conversation

mjdietzx
Copy link
Contributor

@mjdietzx mjdietzx commented Sep 25, 2021

Fuzz test coverage was added around the ExtractDestination(s) functions in
a29f522. This commit contained an incorrect
assertion that the number of required signatures in a multisig script was equal
to the number of addresses. This is incorrect, as for an m-of-n multisig, m <= n.

a29f522 also had an incorrect assertion on
the maximum number of public keys per multisig. It checked that the number of
keys was less than or equal to 16. This is incorrect, as it should be <= 20
(see MAX_PUBKEYS_PER_MULTISIG).

Both of these incorrect assertions are fixed in this commit accordingly.

Note: this is sort of moot because this behavior is deprecated and these
fuzz tests are slated for removal in v23 when the deprecation period for
-deprecatedrpc=addresses ends. However, for correctness and just in case,
it's fixed here.

Noticed here: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=39152
Moot because this PR #22650 gets rid of all this code anyways

Copy link
Member

@darosior darosior left a comment

Choose a reason for hiding this comment

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

The line just above asserts:

assert(required_ret >= 1 && required_ret <= 16);

This is wrong, too. You could have up to 20 keys in a CHECKMULTISIG. Could you correct it too while you're at it?

Fuzz test coverage was added around the ExtractDestination(s) functions in
a29f522. This commit contained an incorrect
assertion that the number of required signatures in a multisig script was equal
to the number of addresses. This is incorrect, as for an m-of-n multisig, m <= n.

a29f522 also had an incorrect assertion on
the maximum number of public keys per multisig. It checked that the number of
keys was less than or equal to 16. This is incorrect, as it should be <= 20
(see MAX_PUBKEYS_PER_MULTISIG).

Both of these incorrect assertions are fixed in this commit accordingly.

Note: this is sort of moot because this behavior is deprecated and these
fuzz tests are slated for removal in v23 when the deprecation period for
-deprecatedrpc=addresses ends. However, for correctness and just in case,
it's fixed here.
@mjdietzx mjdietzx force-pushed the fuzz_extract_destinations_bug_fix branch from c81b149 to 09d29b5 Compare September 25, 2021 14:15
@mjdietzx mjdietzx changed the title fuzz: fix assertion on the number of required sigs in a bare multisig script fuzz: fix checks on number of required sigs and keys in multisig scripts Sep 25, 2021
@mjdietzx
Copy link
Contributor Author

You could have up to 20 keys in a CHECKMULTISIG. Could you correct it too while you're at it?

Nice catch @darosior, I fixed as suggested in this commit

@DrahtBot
Copy link
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #22650 (Remove -deprecatedrpc=addresses flag and corresponding code/logic by mjdietzx)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

Copy link
Member

@darosior darosior left a comment

Choose a reason for hiding this comment

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

utACK 09d29b5

@DrahtBot
Copy link
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".

@mjdietzx
Copy link
Contributor Author

PR #22650 got merged before this, which deleted all of the code this would have corrected, therefore this PR is unnecessary and I'm closing it

@mjdietzx mjdietzx closed this Sep 28, 2021
@mjdietzx mjdietzx deleted the fuzz_extract_destinations_bug_fix branch September 28, 2021 22:35
@bitcoin bitcoin locked and limited conversation to collaborators Oct 30, 2022
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.

4 participants