Tadle

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

lack access control Token Approval Mechanism in `CapitalPool.sol` contract

Summary:

The approve function allows any external address to call it and approve a token address with unlimited spending rights. This function uses a low-level call to interact with the token contract, which can be exploited if the token address is malicious or not implemented correctly. The function does not perform adequate validation of the token address or the token contract’s behavior, leading to potential unauthorized access and misuse of tokens.

Vulnerability Details:

  • Function:

    function approve(address tokenAddr) external {
    address tokenManager = tadleFactory.relatedContracts(
    RelatedContractLibraries.TOKEN_MANAGER
    );
    (bool success, ) = tokenAddr.call(
    abi.encodeWithSelector(
    APPROVE_SELECTOR,
    tokenManager,
    type(uint256).max
    )
    );
    if (!success) {
    revert ApproveFailed();
    }
    }

    The function uses call to invoke the approve method on the token contract specified by tokenAddr, granting unlimited allowance to tokenManager. The function is call by anyone and this method lacks checks to ensure that tokenAddr is a legitimate ERC20 token or not check zero and that it performs the approve function as expected.

Impact:

Allowing anyone to call the approve function without restrictions can lead to significant security risks, including unauthorized token approvals, potential misuse of tokens, and broader vulnerabilities in the system

Tools Used:

Manual review

Recommendations:

  1. Token Address Validation:

    • Ensure that tokenAddr is not a zero address and verify that it conforms to ERC20 standards.

    • Implement a check to confirm that tokenAddr supports the approve function using a safer approach than low-level calls.

  2. Access Control:

    • Restrict access to the approve function so that only authorized addresses or roles can perform the approval action.

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.