Skip to content

fix(asset-ft): validate full extension transfer cost against spendable balance#140

Open
metalarm10 wants to merge 3 commits into
masterfrom
john/fix-asset-ft-frozen-overdebit
Open

fix(asset-ft): validate full extension transfer cost against spendable balance#140
metalarm10 wants to merge 3 commits into
masterfrom
john/fix-asset-ft-frozen-overdebit

Conversation

@metalarm10

@metalarm10 metalarm10 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Closes: https://app.clickup.com/t/868jpxvyf

Description

On the asset/ft extension 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, leaving balance < 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 defeated

Fix

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

  • Unit (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 (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:

  • Try to write more meaningful comments with clear actions to be taken.
  • Nit-picking should be unblocking. Focus on core issues.

Authors checklist

  • Provide a concise and meaningful description
  • Review the code yourself first, before making the PR.
  • Annotate your PR in places that require explanation.
  • Think and try to split the PR to smaller PR if it is big.

This change is Reviewable

@metalarm10 metalarm10 changed the title <DO NOT MERGE - CI check> John/fix asset ft frozen overdebit <DO NOT MERGE - CI check> fix(asset-ft): validate full extension transfer cost against spendable balance Jun 23, 2026
@metalarm10 metalarm10 changed the title <DO NOT MERGE - CI check> fix(asset-ft): validate full extension transfer cost against spendable balance fix(asset-ft): validate full extension transfer cost against spendable balance Jun 23, 2026
@metalarm10 metalarm10 marked this pull request as ready for review June 23, 2026 14:28
@metalarm10 metalarm10 requested a review from a team as a code owner June 23, 2026 14:28
@metalarm10 metalarm10 requested review from bashash, grainerycafe, yivo and ysv and removed request for a team June 23, 2026 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants