Permanent loss of founds for smart contract wallet users if they create orders with WETH
In PreMarket:createOffer()
users can specify the token they whish to use which will be deposited in TokenManager
for them to later withdraw it.
Then, when the offer will be closed/settled, TokenManager:addTokenBalance()
will be called to register funds that the user can withdraw only with the original token used to create the offer:
When the user finally decides to withdraw he will call TokenManager:withdraw()
and receive back his ERC20s or ETH if he created the offer with WETH.
If the user can claim WETH we will enter in the following if case which contains the critical issue:
The critical issue is identified in the use of the primitive transfer()
which enforces a 2300 gas unit limit on the receiver and so will revert if his receive()
function uses more than 2300 gas unit to execute.
For instance, the receive function of the Safe Multisig Wallet will require more then 6k gas to reach the implementation contract and emit an event.
Account Abstraction / smart contract wallet users won't be able to withdraw if they open their position in WETH since their receive()
function will probably consume more than 2300 gas.
Even for owners there's no way to recover those funds, for example by changing the withdrawn token, since TokenManager:addTokenBalance
is only callable by PreMarkets
and DeliveryPlace
.
Add the following test to PreMarket.t.sol
:
Manual review
Foundry
Use call()
instead of transfer()
which doesn't enforce the 2300 gas limit.
Invalid, known issues [Medium-2](https://github.com/Cyfrin/2024-08-tadle/issues/1)
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.