A potential vulnerability in the CapitalPool contract that could allow a malicious contract to cause a denial of service (DoS) attack by calling the approve function.
https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/CapitalPool.sol#L20-L39
https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/TokenManager.sol#L247
The approve function should only be called by the token manager, but in this contract, there is a risk of arbitrary calling of this function.
Write a malicious contract that performs some operations in the approve function, causing the CapitalPool contract to enter a denial of service (DoS) state.
The following is an example:
Attack steps
Deploy the MaliciousToken contract.
Deploy the Attack contract and pass in the CapitalPool contract address and the MaliciousToken contract address.
Call the executeAttack function of the Attack contract.
After calling the executeAttack function, the approve function of the MaliciousToken contract will be called and enter an infinite loop, consuming all the gas, causing the approve function of the CapitalPool contract to fail to execute normally, thus entering a denial of service (DoS) state.
Manual review
By adding permission checks, we ensure that only the token manager can call the approve function, thus preventing attacks from malicious contracts.
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.