Liquid Staking

Stakelink
DeFiHardhatOracle
50,000 USDC
View results
Submission Details
Severity: high
Invalid

contracts/core/ccip/base/SDLPoolCCIPController.sol

This Solidity contract has some well-implemented security measures, but a few areas need attention. Below is a review of potential vulnerabilities or improvements you should address:


1. Lack of Fee Limit on ccipSend

  • Issue: There is no upper-bound validation on the LINK fee for the ccipSend function, beyond msg.value handling. Even though maxLINKFee is defined, it is not enforced in the ccipSend function.

  • Risk: Excess LINK fees could be charged unknowingly.

  • Mitigation: Add a check to ensure the LINK fee does not exceed maxLINKFee.

require(msg.value <= maxLINKFee, "Fee exceeds maximum allowed LINK fee.");

2. Infinite Approvals (approve call)

  • Issue: Approving the router for type(uint256).max can result in abuse if the router becomes compromised or behaves maliciously. This could drain the approved tokens.

  • Mitigation: Use approve only when necessary (e.g., check balances before approvals). Alternatively, adopt dynamic approvals where the exact amount needed is approved for each transaction.


3. Reentrancy Risks in recoverTokens

  • Issue: The recoverTokens function calls safeTransfer in a loop, which transfers tokens. While it uses safeTransfer, a reentrancy guard (via ReentrancyGuard) could prevent more subtle attacks.

  • Mitigation: Add the nonReentrant modifier from OpenZeppelin's ReentrancyGuard to prevent reentrancy attacks.

import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
function recoverTokens(...) external onlyOwner nonReentrant { ... }

4. Centralization Risks with onlyOwner and onlyBridge Modifiers

  • Issue: The onlyOwner and onlyBridge patterns may introduce centralization risks. If the reSDLTokenBridge or owner key is compromised, the contract can be misused for malicious activities.

  • Mitigation:

    • Use multisig wallets for sensitive operations.

    • Consider role-based access control (RBAC) using OpenZeppelin's AccessControl for better management.


5. Lack of Checks in setRouter

  • Issue: If an incorrect router address is set via setRouter, it could lead to a denial of service or misroute messages. Though you already check for address(0), you could also validate whether the address supports the expected interface.

  • Mitigation: Add a contract check to ensure the new router address is a valid router contract.

require(IRouterClient(_router).supportsInterface(type(IRouterClient).interfaceId), "Invalid router address");

6. _verifyCCIPSender Function is Not Implemented

  • Issue: The _verifyCCIPSender function is declared as internal virtual, but it’s not implemented. If this is left unimplemented in inheriting contracts, it could introduce vulnerabilities.

  • Mitigation: Ensure inheriting contracts properly override this function to implement robust sender verification logic.


7. Lack of Event Emission on State Changes

  • Issue: Critical state-changing functions like setMaxLINKFee, setRESDLTokenBridge, and setRouter do not emit events. This limits transparency for off-chain monitoring.

  • Mitigation: Emit events whenever state variables are modified to enhance auditability.

event MaxLINKFeeUpdated(uint256 newMaxLINKFee);
event RouterUpdated(address newRouter);
event BridgeUpdated(address newBridge);
function setMaxLINKFee(uint256 _maxLINKFee) external onlyOwner {
maxLINKFee = _maxLINKFee;
emit MaxLINKFeeUpdated(_maxLINKFee);
}

8. Potential Issues with handleOutgoingRESDL and handleIncomingRESDL

  • Issue: The code does not show the logic for handling outgoing or incoming reSDL tokens, but these functions seem critical.

  • Risk: If these functions are improperly implemented in a derived contract, funds could be stolen or tokens misrouted.

  • Mitigation: Ensure strong access control and input validation in any inheriting contracts that implement these functions.


9. No Protection Against Front-Running

  • Issue: The contract might be vulnerable to front-running attacks, especially in the context of sending CCIP messages or interacting with tokens.

  • Mitigation: Consider using Commit-Reveal patterns or EIP-712 typed data signing for sensitive operations.


Conclusion

This contract is fairly well-structured but could benefit from the above improvements to enhance security and resilience against common smart contract vulnerabilities. Specifically:

  1. Limit LINK fee in ccipSend.

  2. Use dynamic approvals or limit infinite approvals.

  3. Introduce reentrancy guards.

  4. Strengthen access control with events and RBAC.

  5. Implement and enforce _verifyCCIPSender properly.

Let me know if you'd like further help on any of these points!

Updates

Lead Judging Commences

inallhonesty Lead Judge 8 months ago
Submission Judgement Published
Invalidated
Reason: Lack of quality

Support

FAQs

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