Liquid Staking

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

contracts/core/ccip/SDLPoolCCIPControllerPrimary.sol

1. Access Control Issues

  • Critical Functions Limited to onlyOwner:
    Functions such as adding or removing chains and approving reward tokens are restricted by onlyOwner. However, if the ownership isn't managed correctly (like lack of a two-step ownership transfer), it may leave the contract exposed to accidental or malicious changes.

  • onlyRebaseController and onlyUpdateInitiator Roles:
    If these roles are compromised, an attacker could exploit the distributeRewards or executeQueuedUpdates functions, which affect token transfers across chains. Role management should be verified to ensure these addresses can’t be altered maliciously.

Mitigation:

  • Consider adding multi-signature control for critical roles like onlyOwner.

  • Add mechanisms to revoke or reassign the rebaseController and updateInitiator securely.


2. Arithmetic Issues (Overflow/Underflow)

  • The contract uses Solidity 0.8.15, which has built-in overflow/underflow checks, so direct arithmetic vulnerabilities (like in older Solidity versions) are unlikely.

However, arithmetic involving uint256 and int256 conversions may cause problems. Specifically:

if (totalRESDLSupplyChange < 0) {
reSDLSupplyByChain[sourceChainSelector] -= uint256(-1 * totalRESDLSupplyChange);
}

If the value of totalRESDLSupplyChange is extremely large, this conversion could underflow the uint256.

Mitigation:

  • Add bounds checks to ensure the subtraction won't cause underflows.


3. Reentrancy Risk in distributeRewards

IERC677(token).transferAndCall(wrappedToken, tokenBalance, "");
  • The transferAndCall function allows executing arbitrary logic after token transfer. If the wrappedToken contract is malicious or has flawed logic, it could lead to reentrancy attacks, disrupting the state of the rewards distribution.

Mitigation:

  • Use a reentrancy guard on distributeRewards.

  • Ensure trusted contracts are used as wrapped tokens, or carefully validate their behavior.


4. Missing Validations on External Calls

  • Untrusted Chain IDs and Destinations:
    There isn’t a strong check to ensure that chains added via addWhitelistedChain are legitimate. If a malicious owner or compromised account adds a fake chain, rewards could be drained to unintended destinations.

Mitigation:

  • Add checks or whitelists to ensure only legitimate chains and destinations can be added.


5. Gas Limit Misconfiguration Risk

  • Functions like _distributeRewards and executeQueuedUpdates depend on gas limits provided by users. If incorrect gas limits are set:

    • Rewards distribution may fail on destination chains.

    • Critical updates may be stuck in the queue, causing operational failures.

Mitigation:

  • Set default gas limits or use fallback logic if user-provided gas limits are insufficient.


6. Lack of Queued Updates Management

delete queuedUpdates;
  • In executeQueuedUpdates, all updates are cleared after a single execution. If execution partially fails (some updates succeed, some don’t), the contract could lose data about unprocessed updates.

Mitigation:

  • Consider marking updates as processed individually instead of clearing the entire array.

  • Implement event-based logging for failed executions to aid recovery.


7. Fee Limit Misconfiguration

if (fees > maxLINKFee) revert FeeExceedsLimit(fees);
  • The maxLINKFee must be set correctly. If too low, legitimate transactions could be blocked. If too high, it might not protect against excessive fees.

Mitigation:

  • Provide an adaptive fee limit mechanism based on network conditions.


8. Insufficient Validation on Rewards Token Handling

  • There is a potential issue when swapping tokens with wrappedRewardTokens. If the wrapped token logic is flawed or tokens are handled incorrectly, the distribution could fail.

Mitigation:

  • Ensure comprehensive validation of token addresses and balances before swapping and transferring.


Summary of Recommendations

  1. Use reentrancy guards on state-changing functions like distributeRewards.

  2. Ensure safe arithmetic operations during int256 to uint256 conversions.

  3. Improve gas limit management to prevent operational failures.

  4. Implement individual handling of queued updates to avoid data loss.

  5. Strengthen access control mechanisms with multisig or secure role assignment.

  6. Validate wrapped reward tokens and chain whitelisting logic rigorously.


This code is generally well-written but has a few areas where a malicious actor could exploit edge cases. A careful audit and thoughtful improvements should make the contract safer.

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.