The approve
function in the CapitalPool
contract lacks sufficient access control, allowing any external entity to execute it. This vulnerability could lead to unauthorized approval of tokens to the tokenManager
address, potentially resulting in a significant security risk if the tokenManager
is compromised or misconfigured.
Description:
The approve
function within the CapitalPool
contract is publicly accessible, meaning any external address can invoke it. This function approves an unlimited allowance of tokens from the contract to the tokenManager
address. Given the absence of any restrictive access controls, this could allow unauthorized entities to grant unlimited token allowances to the tokenManager
, posing a severe risk if the tokenManager
address is compromised or misconfigured.
Affected Code Snippet:
Vulnerability Summary:
Function: approve(address tokenAddr)
Issue: Lack of access control on the approve
function.
Risk: Unauthorized approval of tokens to the tokenManager
address.
Token Theft: If an attacker can successfully call the approve
function, they can authorize the tokenManager
to spend an unlimited amount of tokens from the CapitalPool
contract. This could lead to the unauthorized draining of the contract's tokens.
Misconfiguration Risk: If the tokenManager
address stored in the tadleFactory
contract is incorrectly set or compromised, it could result in unintended or malicious entities gaining control over the tokens.
Loss of Funds: The exploitation of this vulnerability could result in a complete loss of tokens held within the CapitalPool
contract, leading to significant financial damage.
Implement Access Control:
Restrict the approve
function to only be callable by authorized addresses, such as the contract owner or a specific role (e.g., onlyOwner
, onlyTokenManager
).
Example modification:
Secure tokenManager
Address:
Ensure that the tadleFactory
contract, which provides the tokenManager
address, is secure and only allows trusted addresses to be set as the tokenManager
.
Implement checks to verify the integrity of the tokenManager
address before approval.
Audit Related Contracts:
Conduct a thorough audit of the tadleFactory
and tokenManager
contracts to ensure there are no other vulnerabilities that could be exploited in conjunction with this issue.
Implement Reentrancy Guards (if necessary):
While not directly related to this specific issue, consider implementing reentrancy guards to protect against potential reentrancy attacks, especially if the function is modified to include other state-changing logic in the future.
The approve
function in the CapitalPool
contract poses a significant security risk due to the lack of proper access control. By implementing recommended security measures, including access control modifiers and securing the tokenManager
address, the risk of unauthorized token approvals can be mitigated, protecting the contract from potential exploitation and financial loss.
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.