Since the bid assumes all tokens were sent to the contract, then the ebid.quoteAmount = quoteAmount; will be invalid for tokens with transfer fees. It will be more than the actual tokens received.
One failure in this case will be cancelBid. It will fail because it wants to transfer back ebid.quoteAmount, but there aren’t enough tokens in the contract.
See the notes below for other failing tests.
Mitigation
Check the quoteToken balance before and after token transfer in bid, and use that difference as the ebid.quoteAmount
Lines of code
https://github.com/code-423n4/2022-11-size/blob/main/src/SizeSealed.sol/#L122
Vulnerability details
Some tokens take a transfer fee (e.g.
STA
,PAXG
), some do not currently charge a fee but may do so in the future (e.g.USDT
,USDC
).The
STA
transfer fee was used to drain $500k from several balancer pools (more details).example: TransferFee.sol
Impact
Since the bid assumes all tokens were sent to the contract, then the
ebid.quoteAmount = quoteAmount;
will be invalid for tokens with transfer fees. It will be more than the actual tokens received.One failure in this case will be
cancelBid
. It will fail because it wants to transfer backebid.quoteAmount
, but there aren’t enough tokens in the contract.See the notes below for other failing tests.
Mitigation
Check the quoteToken balance before and after token transfer in
bid
, and use that difference as theebid.quoteAmount
notes
List of failing tests if there is a transfer fee
POC
Use this MockERC20 as the quoteToken in
SizeSealed.t.sol
. Verify that the above tests fail.