The withdraw
function in the contract includes logic that handles the transfer of both ERC20 tokens and native tokens (such as Ether). When withdrawing native tokens, the function uses Solidity's transfer()
method, which uses a fixed gas limit of 2300. However, If the recipient is a smart contract, this gas limit may be insufficient and would lead to the transaction to fail, leading to a denial of service (DoS).
The withdraw
function allows users to withdraw their tokens from the contract. When withdrawing native tokens like ether, the function first converts wrapped native tokens (WETH) back into Ether and then uses Solidity’s transfer()
method to send the Ether to the user.
However, the transfer()
method in Solidity has a fixed gas limit of 2300. If the recipient of the transfer is a smart contract, the contract's receive()
or fallback()
function might require more than 2300 gas to execute due to the unknown logic that this protocol might not be aware of, such as emitting events. This could cause the transaction to fail, leaving the Ether locked in the contract and preventing the user from successfully withdrawing their funds.
The use of the transfer()
method can lead to a denial of service or funds being stucked in the contract
Replace the use of transfer()
with call{value: amount}("")
, which allows specifying a gas limit or providing all available gas, which would reduce such risks
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.