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

fix(ckbtc): use scope guard to prevent double minting #3930

Merged
merged 3 commits into from
Feb 13, 2025
Merged

Conversation

ninegua
Copy link
Member

@ninegua ninegua commented Feb 13, 2025

XC-254

The loop over processable_utxos may keep looping and eventually panic when exceeding the instruction limit if there is a large number of utxos and all of them have a value less than check_fee. If it does panic, then any previous state modification will not be persisted which spells trouble if a previous utxo has already been minted. Although this is a very unlikely scenario, it does still present a non-zero risk.

The fix is to use a scope guard that will be triggered under this situation and update the utxo to a special status to prevent it from being minted again.

@github-actions github-actions bot added the fix label Feb 13, 2025
@ninegua ninegua added the CI_OVERRIDE_DIDC_CHECK Skips the backwards compatibility didc check (explain in PR description why) label Feb 13, 2025
@ninegua ninegua changed the title fix(ckbtc): use separate loops for checking and minting utxos fix(ckbtc): use scope guard to prevent double minting Feb 13, 2025
@ninegua ninegua marked this pull request as ready for review February 13, 2025 09:42
@ninegua ninegua requested a review from a team as a code owner February 13, 2025 09:42
@ninegua ninegua requested a review from gregorydemay February 13, 2025 09:44
Copy link
Member

@gregorydemay gregorydemay left a comment

Choose a reason for hiding this comment

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

Thanks @ninegua for backporting the fix!

@ninegua ninegua added this pull request to the merge queue Feb 13, 2025
Merged via the queue into master with commit d18d04b Feb 13, 2025
29 checks passed
@ninegua ninegua deleted the paulliu/xc-254 branch February 13, 2025 15:06
marko-k0 pushed a commit that referenced this pull request Feb 14, 2025
XC-254

The loop over processable_utxos may keep looping and eventually panic
when exceeding the instruction limit if there is a large number of utxos
and all of them have a value less than check_fee. If it does panic, then
any previous state modification will not be persisted which spells
trouble if a previous utxo has already been minted. Although this is a
very unlikely scenario, it does still present a non-zero risk.

The fix is to use a scope guard that will be triggered under this
situation and update the utxo to a special status to prevent it from
being minted again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI_OVERRIDE_DIDC_CHECK Skips the backwards compatibility didc check (explain in PR description why) @cross-chain-team fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants