Skip to content

Verify network consistency between chain genesis and descriptors #46

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

Open
notmandatory opened this issue Nov 14, 2024 · 4 comments
Open
Assignees
Labels
audit Suggested as result of external code audit

Comments

@notmandatory
Copy link
Member

"Consistency between descriptor network and chain genesis hash isn't checked in load_with_params nor in create_with_params."

@notmandatory notmandatory added the audit Suggested as result of external code audit label Nov 14, 2024
@notmandatory notmandatory moved this to Discussion in BDK Wallet Nov 14, 2024
@oleonardolima
Copy link
Contributor

I'll give this one a try.

@oleonardolima
Copy link
Contributor

oleonardolima commented Dec 13, 2024

Am I missing something or it's actually being verified?

At least as of initial research on create_with_params, it initially uses the Network from CreateParams, gets the genesis_hash, and then uses it on DescriptorToExtract and into_wallet_descriptor.

Later on into_wallet_descriptor implementation, it checks the given network with the parsed descriptor here.

I think I got what I was missing, it's indeed not checking the given genesis_hash in CreateParams with the given Network, when it's a None it'll default to the used one from Network, but the problem relies on the explicitly passed as parameter 🤔.

@oleonardolima
Copy link
Contributor

I'll try to write a test to assert and make sure of the expected behavior.

@oleonardolima
Copy link
Contributor

oleonardolima commented Dec 16, 2024

Alright, we'd probably need a new (e.g. NetworkMistach) error variant, but on DescriptorError, as we need to catch this on both wallet creation and loading. We do have a LoadMismatch::Network but it's only when loading from persisted, and checks the network field.

I'll center the further discussion on PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audit Suggested as result of external code audit
Projects
Status: Discussion
Development

Successfully merging a pull request may close this issue.

2 participants