Tadle

Tadle
DeFiFoundry
27,750 USDC
View results
Submission Details
Severity: low
Valid

Unlimited token approval in `CapitalPool` exposes users to potential complete fund theft if `TokenManager` is compromised

Summary

The approve function in the CapitalPool contract grants an unlimited approval to the TokenManager contract by setting the approval amount to type(uint256).max. This approach poses significant security risks, as it grants unrestricted access to all tokens of that type. If an attacker compromises the TokenManager contract, user funds could be stolen.

Vulnerability Details

The approve function in the CapitalPool contract is defined as follows:

function approve(address tokenAddr) external {
address tokenManager = tadleFactory.relatedContracts(RelatedContractLibraries.TOKEN_MANAGER);
@> (bool success,) = tokenAddr.call(abi.encodeWithSelector(APPROVE_SELECTOR, tokenManager, type(uint256).max)); // @audit-issue unlimited approvals are riskier because if there is a hack user funds could be stolen.
if (!success) {
revert ApproveFailed();
}
}

In this implementation, the function uses type(uint256).max as the approval amount, which effectively grants unlimited access to the TokenManager contract. This can be risky due to the following reasons:

  1. Security Risk: An unlimited approval means that if an attacker gains control over the TokenManager contract or exploits a vulnerability within it, they could potentially transfer all tokens from the user’s account. This represents a significant security risk and could result in the loss of user funds.

  2. Security Standards: Security standards recommend using specific amounts for approvals. This limits the potential damage if a contract is compromised and follows the principle of least privilege, which minimizes the scope of potential attacks.

Impact

The use of unlimited approvals increases the risk of funds being stolen if the TokenManager contract is compromised or if there is a vulnerability within the contract. Users' funds could be at significant risk, as the approval allows for unrestricted access to the token balances.

Tools Used

VSCode

Recommendations

To mitigate this risk, update the approve function to allow specifying a specific uint256 amount instead of using type(uint256).max. This change ensures that the approval is limited to a defined amount, reducing the risk of total loss if the TokenManager contract is compromised.

- function approve(address tokenAddr) external {
+ function approve(address tokenAddr, uint256 amount) external {
- (bool success,) = tokenAddr.call(abi.encodeWithSelector(APPROVE_SELECTOR, tokenManager, type(uint256).max));
+ (bool success,) = tokenAddr.call(abi.encodeWithSelector(APPROVE_SELECTOR, tokenManager, amount));
}
Updates

Lead Judging Commences

0xnevi Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

finding-CapitalPool-approve-missing-access-control

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.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.