Liquid Staking

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

contracts/core/ccip/SDLPoolCCIPControllerSecondary.sol

Here’s an analysis of potential vulnerabilities and improvements in your Solidity code.


1. Reentrancy Vulnerabilities

  • Risk: Functions interacting with external contracts (like safeTransfer to tokens) could allow reentrancy attacks if those contracts are malicious.

  • Recommendation:

    • Use the checks-effects-interactions pattern.

    • Consider adding the nonReentrant modifier (from OpenZeppelin's ReentrancyGuard).

Relevant areas:

sdlToken.safeTransfer(sdlPool, _reSDLToken.amount);
ISDLPoolSecondary(sdlPool).handleIncomingRESDL(_receiver, _tokenId, _reSDLToken);

This code interacts with the external sdlPool contract. If that contract is compromised, it could perform unexpected reentrant calls.


2. Lack of Input Validation

  • Risk: Some parameters are not checked for correctness, which could lead to misuse or unexpected behavior.

  • Recommendation: Add input validation (e.g., require checks) to critical parameters.

Examples:

  1. In setUpdateInitiator():

require(_updateInitiator != address(0), "Invalid update initiator address");
  1. In executeUpdate():

require(_gasLimit > 0, "Gas limit must be positive");

3. Missing Access Control Checks

  • Risk: Some functions like setMinTimeBetweenUpdates() and setUpdateInitiator() are restricted to the onlyOwner modifier. However, if the owner management isn't implemented correctly (inherited from Ownable or similar), it could create attack vectors.

  • Recommendation: Confirm the onlyOwner mechanism is secure and robust. Consider using AccessControl for role-based control if multiple roles are required.


4. Gas Limit Handling Risks

  • Risk: Using dynamic gas limits can introduce issues if the provided _gasLimit is either too low or unnecessarily high, causing transactions to fail or waste gas.

  • Recommendation: Add a cap on the maximum gas limit passed via _gasLimit.

Example:

require(_gasLimit <= MAX_GAS_LIMIT, "Gas limit exceeds allowed cap");

5. Fee Exceeds Limit Handling (Denial of Service Risk)

  • Risk: If the fees for sending cross-chain messages frequently exceed maxLINKFee, the FeeExceedsLimit revert will block all transactions.

  • Recommendation:

    • Implement a fallback mechanism to notify stakeholders or increase the fee cap dynamically if needed.


6. Potential Time Manipulation Risks

  • Risk: block.timestamp can be manipulated by miners within a narrow range. If the timing logic (like minTimeBetweenUpdates) is critical, it could be exploited.

  • Recommendation:

    • Use block numbers or allow a margin for timestamp discrepancies.

Example:

require(block.timestamp >= timeOfLastUpdate + minTimeBetweenUpdates - 15, "Too early to update");

7. Improper Event Emission Coverage

  • Risk: Some state-changing functions (like setUpdateInitiator() or setMinTimeBetweenUpdates()) do not emit events. This makes it harder to trace changes on-chain.

  • Recommendation: Emit events for every important state change.

Example:

event UpdateInitiatorChanged(address oldInitiator, address newInitiator);
event MinTimeBetweenUpdatesChanged(uint64 oldValue, uint64 newValue);
function setUpdateInitiator(address _updateInitiator) external onlyOwner {
emit UpdateInitiatorChanged(updateInitiator, _updateInitiator);
updateInitiator = _updateInitiator;
}

8. Handling Large Token Transfers with Safe Approvals

  • Risk: If multiple token types or large transfers are expected, the allowance mechanism should be carefully managed to avoid "race condition exploits".

  • Recommendation: Ensure safe approval management by resetting allowances to 0 before setting them again.


9. CCIP Message Verification Weakness

  • Risk: The _verifyCCIPSender() function could potentially be tricked if address or chain spoofing vulnerabilities exist.

  • Recommendation: Add additional signature verification or checks to ensure the sender is truly whitelisted.


10. Error Handling Best Practices

  • Risk: Using revert with custom errors is good for gas savings, but it's important to ensure comprehensive coverage to prevent unexpected failures.

  • Recommendation: Ensure all edge cases are covered with appropriate reverts.


Summary of Recommendations

  • Use nonReentrant where necessary to avoid reentrancy.

  • Validate inputs like addresses and gas limits.

  • Cap gas limits and implement a fallback mechanism for fees.

  • Use events for every critical state change.

  • Add block timestamp checks with a margin to prevent miner manipulation.

  • Consider improving the CCIP sender verification with more robust measures.

This review ensures the contract remains safe from common vulnerabilities while maintaining efficiency and control.

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.