Possible DOS (Deny Of Service), contract unable to receive native tokens when using withdraw()
function in TokenManager.sol
, because there is neither :
a receive() external payable
function, nor a fallback() external payable
function in the TokenManager.sol
contract.
https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/TokenManager.sol#L168
Those 2 lines of code cause problem :
In the withdraw()
function from TokenManager.sol
:
withdraw(claimAbleAmount)
will try to send native tokens (unwrapped native tokens) to the TokenManager
contract, but since it doesn't have a receive() payable
function nor a fallback() payable
function, this will throw an error. This contract will not be able to receive the native tokens and won't get to the next line of code that was supposed to
send those native tokens to msg.sender
.
This is a Deny Of Service.
Here is the "unwrapping" function from the wrappNative token contract
:
1) Add an arbitrary amount of native tokens with :
function tillIn(address _accountAddress, address _tokenAddress, uint256 _amount, bool _isPointToken)
via createOffer()::PreMarkets.sol
.
2) Try to withdraw the native tokens with :
function withdraw(address _tokenAddress, TokenBalanceType _tokenBalanceType)
=> Result : The transaction fails.
The user calling the withdraw()
function won't be able to receive his native tokens because the contract is not able to receive native tokens. Deny Of Service.
Foundry, VisualCode.
Mitigation:
Add a receive() external payable
function or a fallback() external payable
function to fix the issue.
Invalid, TokenManager is the implementation contract of 9the transparent upgradeable proxy, as can seen by the comments [here](https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/proxy/UpgradeableProxy.sol#L15). The receive payable is implemented as seen [here](https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/proxy/UpgradeableProxy.sol#L37)
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.