Tadle

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

Missing access control in `CapitalPool::approve` function allows arbitrary contract calls potentially compromising security

Summary

The CapitalPool::approve function currently allows any user to call it and specify an arbitrary contract address to be called. Although the intention is for this function to be callable only by the TokenManager, the current implementation does not enforce this restriction. This oversight poses a security risk, as a malicious contract could exploit this function to harm the Tadle system and its users.

Vulnerability Details

The approve function in the CapitalPool contract is designed to set an unlimited approval for the TokenManager. The function is 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
)
);
if (!success) {
revert ApproveFailed();
}
}

Expected Behavior

The function should only be callable by the TokenManager. This security measure prevents unauthorized access and potential exploitation by malicious actors. As indicated by the comment:

/**
* @dev Approve token for token manager
@> * @notice Only callable by the token manager
* @param tokenAddr Address of the token
*/
function approve(address tokenAddr) external {

Actual Behavior

Currently, the function can be called by any user, as there is no access control mechanism in place. This allows anyone to specify an arbitrary contract address, which could undermine the protocol's security model and potentially lead to unexpected behaviors and vulnerabilities.

Impact

The function's lack of access control means that anyone can call it, despite it being intended for use only by the TokenManager. This could result in a malicious actor providing the address of a malicious contract, which could then harm the Tadle system and its users.

Tools Used

VSCode

Recommendations

Create an access control modifier to restrict the callability of the function to only the TokenManager, as intended.

Updates

Lead Judging Commences

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