Liquid Staking

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

contracts/metisStaking/ccip/SequencerRewardsCCIPSender.sol

Here is a security review of the provided smart contract. Below are potential vulnerabilities and areas of improvement:


1. Unchecked Approvals in initialize() and setRouter()

  • Issue: The contract sets approve() for LINK and METIS tokens with type(uint256).max without controlling approvals in detail.

  • Risk: If the router’s address is compromised or changed to a malicious contract, the tokens might be stolen.

Mitigation:

  • Reset approvals to 0 before re-approving large amounts to prevent front-running attacks.

  • Use OpenZeppelin’s SafeApprove to mitigate approval race conditions:

    linkToken.safeApprove(_router, 0);
    linkToken.safeApprove(_router, type(uint256).max);

2. Missing Validation on initialize() Parameters

  • Issue: In the initialize() function, parameters like _router, _linkToken, and _metisToken are not checked for the zero address (except router during conditionals).

  • Risk: A misconfiguration might lead to unusable or insecure deployments.

Mitigation:

  • Add zero-address checks for all essential parameters:

    if (_linkToken == address(0) || _metisToken == address(0) || _transferInitiator == address(0)) revert ZeroAddress();

3. No Rate-Limiting or Throttling for transferRewards()

  • Issue: The transferRewards() function could be called repeatedly by the authorized initiator, draining all rewards unexpectedly.

  • Risk: A malicious or compromised transfer initiator could rapidly deplete rewards through spamming.

Mitigation:

  • Implement time-based limits or circuit breakers to control how often transfers can occur.


4. Authorized Initiator Can Abuse Transfers

  • Issue: The onlyTransferInitiator modifier enforces authorization, but once set, the initiator has complete control over reward transfers.

  • Risk: If the transfer initiator’s key is compromised, all funds could be transferred to a malicious destination.

Mitigation:

  • Allow the owner to pause transfers in emergencies or implement multisig controls for setting critical parameters.

  • Add a pause() / unpause() mechanism with OpenZeppelin’s PausableUpgradeable.


5. Vulnerable to Front-Running on _maxLINKFee

  • Issue: The transferRewards() function allows a transfer only if the LINK fee is below _maxLINKFee. However, the fee might change between the time the transaction is submitted and executed, leading to a front-running vulnerability.

  • Risk: The transaction might be unexpectedly reverted due to fluctuating fees.

Mitigation:

  • Consider adding a buffer range or an upper-bound margin for fees to reduce this risk.


6. No Event for Critical Parameter Changes

  • Issue: Changes to sensitive parameters like the router address or transfer initiator do not emit events.

  • Risk: Hard to track changes and detect malicious behavior.

Mitigation:

  • Emit events when sensitive parameters are updated:

    event TransferInitiatorSet(address indexed initiator);
    event RouterSet(address indexed router);

7. Lack of Fallback Mechanism for Token Recovery

  • Issue: If tokens other than LINK or METIS are accidentally sent to the contract, they might be locked.

  • Risk: Inaccessible funds might accumulate over time.

Mitigation:

  • Add a rescueTokens() function for the owner:

    function rescueTokens(IERC20Upgradeable token, uint256 amount) external onlyOwner {
    token.safeTransfer(msg.sender, amount);
    }

8. Potential Storage Collision Risks in UUPS Upgradeable Contracts

  • Issue: With UUPS proxies, storage layout mismatches during upgrades can introduce vulnerabilities or unexpected behavior.

  • Risk: Incorrect upgrades could brick the contract.

Mitigation:

  • Ensure proper storage layout management and careful upgrade testing.

  • Add access control checks or restrictions on the _authorizeUpgrade() function:

    function _authorizeUpgrade(address newImplementation) internal override onlyOwner {
    require(newImplementation != address(0), "Invalid implementation");
    }

Summary of Issues and Mitigations

Issue Risk Level Mitigation
Unchecked approvals Medium Use safeApprove()
Missing parameter validation Medium Check for zero addresses
No rate-limiting for rewards transfer High Add throttling/circuit breaker
Abuse by authorized initiator High Add pause mechanism
Front-running on _maxLINKFee Medium Add fee buffer
No events for critical updates Low Emit events for changes
Locked tokens without recovery function Low Add rescueTokens()
Storage collision in UUPS upgrades Medium Proper storage management

Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Lack of quality

Support

FAQs

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