Liquid Staking

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

contracts/ethStaking/EthStakingStrategy.sol

Reviewing the provided Solidity code for the EthStakingStrategy contract, I’ve identified several potential vulnerabilities and areas for improvement:

1. Access Control Vulnerabilities

  • The function reportBeaconState checks if the caller is beaconOracle. However, if this address is set incorrectly (e.g., to a malicious actor), they can manipulate the beacon state.

  • Similar access control checks should be carefully managed for functions that could potentially lead to malicious state changes, like depositEther, which requires the caller to be depositController.

2. Use of require Statements

  • The require statements that check for valid states may allow a malicious actor to manipulate contract behavior if they have control over the respective addresses (like beaconOracle or depositController). Consider implementing role-based access control (RBAC) or an upgradable pattern to manage permissions more robustly.

3. Reentrancy Attacks

  • The contract interacts with external contracts (depositContract and rewardsReceiver) without protection against reentrancy. Using a reentrancy guard (e.g., the OpenZeppelin ReentrancyGuard contract) can help mitigate this risk. Consider applying it especially to the depositEther and _deposit functions where external calls are made.

4. Unbounded Operations

  • The for loops in the depositEther function that call _deposit could potentially run out of gas if _nwlTotalValidatorCount or _wlTotalValidatorCount is too high. There should be checks to limit the number of deposits processed in a single transaction.

5. Incorrect Withdrawal Credentials Check

  • In the _deposit function, checking require(withdrawalCredentials != 0, "Empty withdrawal credentials"); might not be sufficient. The check should ensure that withdrawalCredentials is not an invalid state (e.g., an uninitialized address or a specific default value).

6. Unvalidated Inputs

  • Several inputs are taken from user input or external contracts without validation (e.g., lengths of arrays in depositEther). Ensure these values are within expected bounds and do not allow for unexpected behavior or exploits.

7. Handling of Ether and Wrapped ETH

  • The contract unwraps WETH in depositEther and handles Ether directly, which can introduce risks if the contract does not properly account for the differences between the two. The flow of funds should be carefully monitored to prevent accidental loss or locking of funds.

8. Event Emission

  • While events are emitted for state changes, consider emitting events for all critical state changes, including those in reportBeaconState, to ensure that the contract's operations can be monitored effectively.

9. No Fallback Mechanism for Deposit Failures

  • The contract does not provide a fallback mechanism if a deposit fails. If depositContract.deposit fails, it can result in unexpected contract states. Implement proper error handling.

10. Potential Integer Overflow/Underflow

  • Although Solidity 0.8.x has built-in overflow/underflow protection, double-check the logic of arithmetic operations to ensure they don’t lead to unintended states or logic errors.

Recommendations:

  • Implement a more robust access control mechanism.

  • Introduce reentrancy guards where external calls occur.

  • Validate all inputs thoroughly to prevent unexpected behaviors.

  • Add event logging for all critical state changes.

  • Establish limits on loops to avoid gas issues.

  • Consider utilizing more comprehensive patterns for contract upgrades and administration.

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.