#37903 [SC-High] "Potential Underflow Vulnerability in burn Function for total_active_stake_key"
Description
Brief/Intro
Vulnerability Details
@router.method(no_op=CallConfig.CALL)
def burn(send_xalgo: abi.AssetTransferTransaction, min_received: abi.Uint64) -> Expr:
burn_amount = send_xalgo.get().asset_amount()
algo_balance = ScratchVar(TealType.uint64)
algo_to_send = ScratchVar(TealType.uint64)
return Seq(
rekey_and_close_to_check(),
# ensure initialised
Assert(App.globalGet(initialised_key)),
# check xALGO sent
check_x_algo_sent(send_xalgo),
# update total rewards
update_total_rewards_and_unclaimed_fees(),
# calculate algo amount to send
algo_balance.store(
App.globalGet(total_active_stake_key)
+ App.globalGet(total_rewards_key)
- App.globalGet(total_unclaimed_fees_key)
),
algo_to_send.store(
mul_scale(
burn_amount,
algo_balance.load(),
get_x_algo_circulating_supply() + burn_amount
)
),
# check amount and send ALGO to user
Assert(algo_to_send.load()),
Assert(algo_to_send.load() >= min_received.get()),
send_algo_from_proposers(Txn.sender(), algo_to_send.load()),
# update total active stake
App.globalPut(total_active_stake_key, App.globalGet(total_active_stake_key) - algo_to_send.load()),
# log burn
Log(Concat(
MethodSignature("Burn(address,uint64,uint64)"),
Txn.sender(),
Itob(burn_amount),
Itob(algo_to_send.load()),
)),
)Impact Details
Proof of Concept
Proof of Concept
Previous#37889 [SC-High] Underflow in `burn()` function will cause user funds to partially frozenNext#37893 [SC-Insight] inflation attack in xalgo
Last updated
Was this helpful?