Tadle

Tadle
DeFiFoundry
27,750 USDC
View results
Submission Details
Severity: low
Invalid

Withdrawing funds may get stuck due to transfer gas limit

Summary

Withdrawing funds may get stuck due to transfer gas limit

Vulnerability Details

https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/TokenManager.sol#L169

Using payable(msg.sender).transfer(claimAbleAmount); can be an issue because it might fail if the msg.sender is a contract with a complex fallback function or if the gas cost of the transaction is high. The transfer method only forwards a limited amount of gas (2300 units), which is enough for simple operations but not for more complex contract functions.

If msg.sender is a contract with a fallback function that requires more than 2300 gas to execute, the transfer will fail, causing the entire TokenManager::withdraw function to revert. This means the user won’t receive their withdrawal amount, and the transaction will fail, even though the contract has enough funds to pay them.

As a result users(contracts) might not get their payments due to gas limitations.

Impact

Impact: High
Likelihood: Low

Proof of Concept

By calling the TokenManager::withdraw provided that the msg.sender has something to withdraw, and the msg.sender is a contract whose receive()/fallback() functions which would require more than 2300 gas to execute.

Tools Used

Manual Review

Recommendations

Inside TokenManager::withdraw use .call instead of transfer():

...
if (_tokenAddress == wrappedNativeToken) {
/**
* @dev token is native token
* @dev transfer from capital pool to msg sender
* @dev withdraw native token to token manager contract
* @dev transfer native token to msg sender
*/
_transfer(
wrappedNativeToken,
capitalPoolAddr,
address(this),
claimAbleAmount,
capitalPoolAddr
);
IWrappedNativeToken(wrappedNativeToken).withdraw(claimAbleAmount);
- payable(msg.sender).transfer(claimAbleAmount);
+ (bool success, ) = payable(msg.sender).call{value: claimAbleAmount}("");
++ require(success, "Transfer failed");
} else {
...
}
...
Updates

Lead Judging Commences

0xnevi Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Known issue
Assigned finding tags:

[invalid] finding-TokenManager-withdraw-transfer-2300-gas

Invalid, known issues [Medium-2](https://github.com/Cyfrin/2024-08-tadle/issues/1)

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!