Submitted by neko_nyaa, also found by _141345_, 0x52, 0xc0ffEE, 0xSmartContract, c7e7eff, cccz, cryptostellar5, fs0c, hansfriese, horsefacts, Josiah, KingNFT, ladboy233, Lambda, minhtrng, pashov, R2, RaymondFam, Ruhum, rvierdiiev, sashik_eth, TomJ, tonisives, Trust, TwelveSec, and wagmi.
https://github.com/code-423n4/2022-11-size/blob/main/src/SizeSealed.sol#L163
https://github.com/code-423n4/2022-11-size/blob/main/src/SizeSealed.sol#L96-L105
The following report describes two issues with how the SizeSealed contract incorrectly handles several so-called weird ERC20 tokens, in which the tokens balance can change unexpectedly:
Let us first note how the contract attempts to handle sudden balance change to the baseToken:
https://github.com/code-423n4/2022-11-size/blob/main/src/SizeSealed.sol#L96-L105
The effect is that the operation will revert with the error UnexpectedBalanceChange() if the received amount is different from what was transferred.
Unlike base tokens, there is no such check when transferring the quoteToken from the bidder:
https://github.com/code-423n4/2022-11-size/blob/main/src/SizeSealed.sol#L163
Since line 150 stores the quoteAmount as a state variable, which will be used later on during outgoing transfers (see following lines), this results in incorrect state handling.
It is worth noting that this will effect all functions with outgoing transfers, due to reliance on storage values.
Consider the following scenario, describing the issue with both token types:
For Alices situation, she is able to recover her original amount. However, since aTokens increases ones own balance over time, the interest amount is permanently locked in the contract.
Bobs situation is somewhat more recoverable, as he can simply send more tokens to the contract itself, so that the contracts balance is sufficient to refund Bob his tokens. However, given that Bob now has to incur more transfer fees to get his own funds back, I consider this a leakage of value.
It is worth noting that similar impacts will happen to successful auctions as well, although it is a little more complicated, and that it varies in the matter of who is affected.
For the base token:
For the quote token:
While technically two separate issues are described, they do have many overlappings, and both comes down to correct handling of unusual ERC20 tokens, hence I have decided to combine these into a single report.
Another intention was to highlight the similarities and differences between balance handling of base tokens and quote tokens, which actually has given rise to part of the issue itself.
For both issues:
For the base token issue:
For the quote token issue:
Additionally, consider using a separate internal function for pulling tokens, to ensure correct transfers.
0xean (judge) commented on duplicate issue #255:
Ragepit (SIZE) confirmed duplicate issue #255
0xean (judge) commented on duplicate issue #255:
