flan can’t be transferred unless the flan contract has flan balance greater than the amount we want to transfer
The safeTransfer function in the Flan contract checks the contract's own balance instead of the sender's balance, so transfers only work if the contract holds enough tokens. An attacker could not steal funds, but users cannot transfer their own flan unless the contract has a sufficient balance.
Originally disclosed on Code4rena
Submitted by CertoraInc
Flan.sol (safeTransfer() function)
The flan contract must have balance (and must have more flan then we want to transfer) in order to allow flan transfers. If it doesn’t have any balance, the safeTransfer, which is the only way to transfer flan, will call _transfer() function with amount = 0. It should check address(msg.sender)’s balance instead of address(this)’s balance.
function safeTransfer(address _to, uint256 _amount) external {
uint256 flanBal = balanceOf(address(this)); // the problem is in this line
uint256 flanToTransfer = _amount > flanBal ? flanBal : _amount;
_transfer(_msgSender(), _to, flanToTransfer);
}
gititGoro (Behodler) confirmed but disagreed with High severity
Jack the Pug (judge) decreased severity to Medium and commented:
Downgrade to medium as there is no fund at risk.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The safeTransfer function uses balanceOf(address(this)) instead of balanceOf(msg.sender) to determine the transferable amount.
Impact
Users cannot transfer their flan unless the contract itself has a balance greater than the amount, but no funds are at risk.
What the attacker needed
Contract must have flan balance; user must call safeTransfer
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
This is a smart contract bug where a transfer function looks at the wrong account's balance. Instead of checking how many tokens the person sending them has, it checks how many the contract itself holds. That means normal transfers fail unless the contract happens to have enough tokens, which is not how a token transfer should work.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.