The CapitalPool::approve
function approves tokens for TokenManager.sol
to transfer from one address to the other.
The CapitalPool::approve
function is only supposed to be called by the TokenManager.sol
as specied in the natspec
Notice that the function is marked external
with no access control which means it can be called by any other contract.
Because the CapitalPool::approve
function does not have any access controls, a malicious actor can approve a weird ERC20 token into the protocol.
Manual Review and Foundry
Proof of Concept:
A malicious user creates a weird ERC20 token and a smart contract
The malicious user's contract calls the CapitalPool::approve
passing the weird ERC20 token to be approved.
Now place the following code inside PreMarketsTest
contract in PreMarkets.t.sol
.
Run: forge test --match-test test_CapitalPool_Approve_CanBeCalledByAnyone
Output:
Consider modifying the CaptialPool::approve
function to check if the caller is TokenManager.sol
.
This will ensure that only TokenManager.sol
can call the CapitalPool::approve
function and thereby approve tokens on the protocol.
This is at most low severity, even though giving max approvals shouldn't be permisionless, the respective tokenManager address is retrieved from the TadleFactory contract whereby the trusted guardian role is responsible for deploying such contracts as seen [here](https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/factory/TadleFactory.sol#L68). Since the user still has to go through the PreMarkets/DeliveryPlace contracts to perform market actions, this max approval cannot be exploited.
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.