Tadle

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

CapitalPool::approve Function Lacks Access Control for TokenManager

Summary

The CapitalPool::approve function is intended to be called only by the TokenManager, as stated in the function's documentation. However, there is no access control check to enforce this restriction. This oversight allows any external address to call the function.

Vulnerability Details

/**
* @dev Approve token for token manager
* @notice only can be called by token manager
* @param tokenAddr address of token
*/
// @audit high only the tokenManger can call this 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 approve function is designed to approve the TokenManager to spend tokens on behalf of the CapitalPool, facilitating user withdrawals. However, there is no access control check in place to ensure that only the TokenManager can call this function, despite this being a critical requirement as per the function's documentation. The lack of such a check could allow malicious actors to call the function and manipulate token approvals.

Impact

The lack of access control on the approve function could lead to unauthorized token approvals, potentially allowing malicious actors to manipulate token transfers. This could result in significant financial losses for the protocol and its users

Tools Used

Manual code Review

Recommendations

Implement an access control check to ensure that only the TokenManager can call the approve function. This can be done by adding a require statement that checks the caller's address:

require(
msg.sender == tadleFactory.relatedContracts(RelatedContractLibraries.TOKEN_MANAGER),
"Caller is not TokenManager"
);
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.