fix(wallet/melt): replace panicking + with checked_add in saga#2137
Draft
asmogo wants to merge 2 commits into
Draft
fix(wallet/melt): replace panicking + with checked_add in saga#2137asmogo wants to merge 2 commits into
asmogo wants to merge 2 commits into
Conversation
Amount::add uses .expect() which panics on overflow. A malicious mint returning a melt quote with amount + fee_reserve near u64::MAX would crash the wallet process. Replace all 6 arithmetic additions on mint-supplied amounts in the melt saga with checked_add, propagating Error::AmountOverflow instead of panicking. Affected sites: - wallet/melt/saga/mod.rs: lines 299, 389, 487, 678, 706 - wallet/melt/mod.rs: change_amount_without_swap (line 476)
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2137 +/- ##
==========================================
+ Coverage 71.55% 71.59% +0.04%
==========================================
Files 356 356
Lines 73999 74126 +127
==========================================
+ Hits 52950 53073 +123
- Misses 21049 21053 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Amount::add uses .expect() which panics on overflow. A malicious mint returning a melt quote with amount + fee_reserve near u64::MAX would crash the wallet process. Replace all 6 arithmetic additions on mint-supplied amounts in the melt saga with checked_add, propagating Error::AmountOverflow instead of panicking.
Affected sites:
Description
Notes to the reviewers
Suggested CHANGELOG Updates
CHANGED
ADDED
REMOVED
FIXED
Checklist
just quick-checkbefore committingcrates/cdk-ffi)