fix(asset-ft): validate full extension transfer cost against spendable balance#140
Open
metalarm10 wants to merge 3 commits into
Open
fix(asset-ft): validate full extension transfer cost against spendable balance#140metalarm10 wants to merge 3 commits into
metalarm10 wants to merge 3 commits into
Conversation
ysv
approved these changes
Jun 29, 2026
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.
Closes: https://app.clickup.com/t/868jpxvyf
Description
On the
asset/ftextension transfer path, the spendable check validated only the bare send amount, but the sender is actually debited amount + commission + burn. When freezing is enabled, that surcharge gap is silently drawn from the holder's frozen balance (the raw bank keeper has no frozen-store awareness) - draining compliance-locked tokens, leavingbalance < frozen, and bricking the account.Trigger: token has freezing + extension, burn and/or commission rate > 0, admin froze part of the holder's balance, holder is not the admin.
Attack flow:
holder sends exactly their unfrozen quota → spendable check passes on the bare amount → extension is debited amount+commission+burn via raw bank → the commission+burn portion comes out of frozen funds → balance < frozen, freeze defeatedFix
On the extension path, validate spendability against the full debit (
amount + commission + burn) instead of the bare amount. The non-extension path is unchanged - it already pre-debits commission and burn before validation, so its bare-amount check is correct.Test
x/asset/ft/keeper): with a wasm extension contract and 0.5 burn / 0.5 commission, an over-debit transfer into frozen funds is rejected, the frozen reserve stays intact, and a within-budget transfer still succeeds.integration-tests/modules): same scenario end-to-end on znet.Both fail without the fix (the over-debit succeeds and drains the frozen reserve) and pass with it.
Reviewers checklist:
Authors checklist
This change is