Tadle

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

Lack of Access Control For `CapitalPool::approve`

Summary

The CapitalPool::approve function is intended to be called only by the tokenManager, as stated in the documentation. However, there is no access control implemented in the function, allowing anyone to call it. This can lead to arbitrary external calls, which may result in unintended or malicious behavior.

Vulnerability Details

The CapitalPool::approve function is designed to grant the tokenManager maximum allowance for a specified token:

/**
* @dev Approve token for token manager
@=> * @notice only can be called by token manager
* @param tokenAddr address of token
*/
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();
}
}

According to the comment, this function should only be callable by the tokenManager. However, the function lacks any access control mechanism to enforce this restriction. As a result, any external address can call the approve function, triggering an arbitrary external call to any specified address.

This is not only inconsistent with the intended design but also poses potential significant security risks. An attacker could potentially exploit this to initiate external calls that could result in unintended behavior, especially when the contract is being used to store funds.

The POC is shown below:

function test_arbitray_call() public {
vm.startPrank(user1);
capitalPool.approve(user1);
}

In this example, user1 is able to call the approve function and initiate an external call, which is not the intended behavior.

Impact

This vulnerability allows anyone to execute arbitrary external calls through the CapitalPool::approve function. Though the call is being limited to approve, this could still pose potential risks.

Tools Used

Manual, Foundry

Recommendations

Add access control to the approve function to ensure that only the tokenManager can call it.

Updates

Lead Judging Commences

0xnevi Lead Judge over 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.

Give us feedback!