withdraw() function wont work when trying to withdraw wrapped Native Tokens as wrong argument is supplied as token address for capitalPool.approve() which is called later in the withdraw() function logic via the internal _transfer() function.
tokenManager.withdraw() will attempt to withdraw wrapped native tokens from the capital pool before converting them to ETH and sending that to the caller. The pull of tokens from the capital pool will occur via the internal _transfer() function.
In the _transfer() function, before a safeTransferFrom is used by tokenManager to take the tokens from the capital pool, _capitalPool.approve is called so that tokenManager is granted permission to take these tokens from the capital pool. But it is called with a wrong parameter in tokenManager._transfer(). The function _capitalPool.approve() ought to be called with a token address as parameter as specified by the function's selector. _capitalPool.approve() snippet below.
But instead, tokenManager._transfer() supplies its own address when calling the _capitalPool.approve() function (See snippet below). Token manager is not an erc20 token so it doesn't even have an approve function.
The call to _capitalPool.approve does cause the whole execution to revert with an ApproveFailed() error as the function approve() does not exist on tokenManager's address which was supplied to the _capitalPool.approve() fcn. Snippet of _capitalPool.approvebelow showing the required parameter for the function.
The POC test below fails with this revert statement below
To run the POC test:
paste code in new file in /test folder
run with fforge test --mt test_capitalPoolApproveFails -vvv
inability of users to withdraw claimabale amount as ETH because of wrong token address being used as parameter in an external function call to _capitalPool.approve()
foundry
pass in the token address in tokenManager._transfer() like below
If we consider the correct permissioned implementation for the `approve()` function within `CapitalPool.sol`, this would be a critical severity issue, because the withdrawal of funds will be permanently blocked and must be rescued by the admin via the `Rescuable.sol` contract, given it will always revert [here](https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/CapitalPool.sol#L36-L38) when attempting to call a non-existent function selector `approve` within the TokenManager contract. The argument up in the air is since the approval function `approve` was made permisionless, the `if` block within the internal `_transfer()` function will never be invoked if somebody beforehand calls approval for the TokenManager for the required token, so the transfer will infact not revert when a withdrawal is invoked. I will leave open for escalation discussions, but based on my first point, I believe high severity is appropriate.
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.