Liquid Staking

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

contracts/metisStaking/SequencerVCS.sol

The provided smart contract contains a number of potential vulnerabilities and risks. Below is an analysis of security issues, areas of improvement, and best practices that could help mitigate these risks:


1. Reentrancy Risks

  • Potential Issue: Although the contract uses SafeERC20Upgradeable for token transfers, which generally protects against reentrancy, certain functions interact with external vault contracts (e.g., depositQueuedTokens and updateDeposits) that could potentially introduce reentrancy vulnerabilities.

  • Mitigation:

    • Consider implementing reentrancy guards (nonReentrant modifiers) where multiple external calls to vaults or token occur within the same function (e.g., updateDeposits).

    • Ensure that no logic (such as state updates) is executed after external calls to untrusted contracts.


2. Missing Zero-Address Checks

  • Issue:

    • In addVault, the _signer and _rewardsReceiver addresses are used without checking if they are address(0).

    • This could introduce vulnerabilities by enabling the deployment of vaults with invalid addresses.

  • Mitigation: Add a check:

    if (_signer == address(0) || _rewardsReceiver == address(0)) revert ZeroAddress();

3. Fees Calculation Logic Could Be Exploited

  • Issue: The updateDeposits and getPendingFees functions loop through fees and vaults to calculate rewards based on a percentage of the deposit change. If malicious vaults report incorrect reward values, this could result in inaccurate fees or improper distribution.

  • Mitigation: Ensure that only authorized vaults with trusted logic are used, and consider implementing additional sanity checks on reported values.


4. Operator Rewards Calculation Vulnerability

  • Issue:

    • In withdrawOperatorRewards, there is a risk of integer underflow in the following line if _amount exceeds unclaimedOperatorRewards:

      unclaimedOperatorRewards -= amountToWithdraw;
    • Since Solidity 0.8.x automatically reverts on underflow, this won't result in silent failure, but it’s better to handle it gracefully.

  • Mitigation: Add a sanity check:

    require(_amount <= unclaimedOperatorRewards, "Amount exceeds unclaimed rewards");

5. Lack of Withdrawal Implementation

  • Issue: The withdraw function currently reverts with "withdrawals not yet implemented". This could create issues if users or stakeholders expect to recover funds but cannot do so.

  • Mitigation: Clearly document this in the contract's usage instructions and consider implementing at least emergency withdrawal logic.


6. Vault Upgrade Logic Is Truncated / Unprotected

  • Issue: The upgradeVaults function starts upgrading vaults but is truncated, and there is no access control beyond onlyOwner. Without a detailed implementation, upgrading vaults could lead to unintended behavior or vulnerabilities if used incorrectly.

  • Mitigation:

    • Implement more granular access control to limit who can upgrade vaults.

    • Ensure that initialization data for the vaults during upgrade is validated and consistent.


7. Lack of Validation for External Calls in addVault

  • Issue: The call to ERC1967Proxy in addVault relies on external input (_pubkey, _signer) without thorough validation. If these inputs are invalid, it could lead to the deployment of non-functional or malicious vaults.

  • Mitigation: Add validation for inputs and verify that the vaultImplementation is correct and functioning.


8. Unbounded Loops: Gas Limit Vulnerability

  • Issue: Functions such as depositQueuedTokens and updateDeposits loop through vaults, which could lead to out-of-gas issues if the number of vaults becomes too large.

  • Mitigation: Consider implementing batching or pagination for these operations to avoid gas exhaustion.


9. Use of payable without Proper Authorization in withdrawETH

  • Issue: The withdrawETH function allows any onlyOwner address to withdraw all ETH in the contract, which could become problematic if the owner address is compromised.

  • Mitigation:

    • Implement multi-signature approval or timelocks for sensitive operations like ETH withdrawal.

    • Consider logging more detailed events (e.g., withdrawal amount and recipient).


10. Missing Events for Critical Actions

  • Issue: Critical actions like withdrawOperatorRewards, depositQueuedTokens, or ETH withdrawals do not emit events, making it difficult to trace them via logs.

  • Mitigation: Emit events for better transparency:

    event OperatorRewardsWithdrawn(address receiver, uint256 amount);
    event ETHWithdrawn(address receiver, uint256 amount);

Conclusion and Recommendations

This contract has a solid structure, but there are a few areas where vulnerabilities might arise due to:

  1. Lack of validation and input checks.

  2. Unprotected external calls.

  3. Gas limit vulnerabilities due to unbounded loops.

  4. Insufficient events for traceability.

Recommended Changes:

  1. Add input validation for zero addresses.

  2. Implement reentrancy guards.

  3. Use batching for operations involving multiple vaults.

  4. Emit events for critical functions.

  5. Add emergency withdrawal logic to handle edge cases.

These changes will strengthen the contract and make it more secure and maintainable.

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.