Liquid Staking

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

contracts/ethStaking/NWLOperatorController.sol

Reviewing the provided Solidity code for potential vulnerabilities, several areas deserve attention:

1. Reentrancy Vulnerability

  • The removeKeyPairs and withdrawStake functions call external contracts (using .call), which can lead to reentrancy attacks. Although you are using the checks-effects-interactions pattern generally, it's best practice to utilize a reentrancy guard (e.g., nonReentrant modifier from OpenZeppelin).

2. Arithmetic Issues

  • Solidity 0.8.0 and above use built-in overflow checks, which is good. However, keep an eye on the logic to ensure that underflows do not occur. For example, the arithmetic in the reportStoppedValidators function can lead to overflows or underflows if not properly checked, even with the built-in checks.

3. Gas Limit and Loops

  • The assignNextValidators and getNextValidators functions contain loops that depend on the length of queue. If queue grows large, these functions could consume too much gas, leading to transaction failures. Consider implementing a gas limit or a batching mechanism.

4. Access Control

  • Ensure that the onlyKeyValidationOracle, onlyEthStakingStrategy, and onlyBeaconOracle modifiers are adequately defined and restrict access correctly. Without proper implementation, they could allow unauthorized access.

5. Public State Variables

  • The ethLost and ethWithdrawn mappings are public, which means they can be accessed by anyone. If these mappings are intended to hold sensitive data, consider implementing getters to control the exposure of this information.

6. Event Emission for Critical Operations

  • Consider emitting events for critical operations such as the withdrawal of stakes, changes in state, or significant state variables (e.g., when operators are added/removed). This enhances transparency and traceability.

7. Magic Numbers

  • The constant DEPOSIT_AMOUNT is hardcoded to 16 ether. It would be beneficial to document this value or consider making it configurable, depending on your application's requirements.

8. Incomplete Error Messages

  • The error messages in require statements could be more descriptive. Instead of just indicating that an error occurred, provide details about the expected conditions. This is especially important for debugging in production.

9. Potentially Unused Variables

  • Variables like toRemove in the removeKeyPairs function may be assigned but not used effectively. Review to ensure they serve a purpose in the code logic.

10. Lack of Input Validation

  • While you have some require checks, ensure all parameters are properly validated before processing, especially in functions like addKeyPairs and removeKeyPairs.

11. State Variables Initialization

  • Make sure all state variables are initialized properly to avoid relying on default values, especially in complex structs like operators.

Recommendations:

  • Implement a reentrancy guard on functions that modify state and call external contracts.

  • Review gas limits on functions with loops and consider adding checks to prevent excessive gas usage.

  • Enhance access control and ensure that only authorized parties can execute sensitive functions.

  • Add thorough documentation and comments for complex logic and important constants.

Overall, while the code appears functional, addressing the above areas will enhance its security and reliability.

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.