Liquid Staking

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

scripts/prod/1.0.0-metis-staking/3-setup-metis-staking.ts

To assess potential vulnerabilities in this code, let’s break down critical areas and identify some common issues in smart contract interaction and deployment scripts.

Potential Vulnerabilities in the Code


1. Unchecked Return Values / Misuse of .wait()

  • In the code, you are awaiting the transaction promises directly with .wait(), assuming they succeed.

    • Risk: If a transaction fails or reverts (e.g., due to insufficient gas, invalid state, or misconfigurations), it could leave the system in a partially configured state.

    • Mitigation:

      • Ensure proper error handling for specific calls (e.g., validate state before interacting).

      • Consider checking for expected states between steps to catch silent failures.


2. Ownership Transfer Risks

  • Transferring ownership to a multisig address without verification might introduce risks:

    • Risk: If the multisig is not correctly set up or compromised, the system could lose access control.

    • Mitigation:

      • Verify the multisig address is correctly configured before the transfer.

      • Ensure fallback mechanisms (like a time-locked contract) to mitigate ownership mishandling or misconfiguration.


3. Hardcoded Multisig Address

  • The multisig address is hardcoded into the code:

    • Risk: This could introduce inflexibility or errors if the address changes.

    • Mitigation: Consider reading the address from a configuration file or environment variables to allow flexibility.


4. Potential for Misconfiguration in Contract Setup

  • The configuration sequence involves multiple contracts. If one call fails silently, it can result in an inconsistent state.

    • Risk: For example:

      • If setPriorityPool or addStrategy fails but isn’t caught, the staking pool may not function correctly.

      • Incorrect DistributionOracle assignment might cause unexpected behavior in reward distribution.

    • Mitigation: Add assertions to verify contract states after key configurations (e.g., ensure priorityPool is correctly set before moving on).


5. Gas Issues with Multiple Contract Calls

  • The script performs multiple contract calls sequentially. If one of them is gas-intensive, it may fail mid-execution.

    • Mitigation: Monitor gas usage and, if necessary, batch transactions to minimize risk.


6. Lack of Role or Access Control Checks

  • Risk: If the getContract utility does not properly verify the caller’s access to certain methods (like transferOwnership), it might allow unintended transfers.

    • Mitigation: Ensure the getContract function checks proper roles and access levels.


7. CCIP and Oracle Risks

  • Assigning the CCIP controller and oracle in critical infrastructure might introduce new attack vectors.

    • Risk: If these components are compromised or misconfigured, rewards distribution could be disrupted.

    • Mitigation: Ensure the security of these dependencies (e.g., validate the rewardsReceiver logic and oracle data sources).


Additional Recommendations

  1. Logging Transaction Hashes: Add logs to track transaction hashes for easier debugging in case of issues.

  2. Test with Edge Cases: Ensure the contracts are tested for scenarios like insufficient gas, reentrancy risks, and invalid state transitions.

  3. Audit Contracts: Conduct a thorough security audit of the underlying contracts (e.g., StakingPool, PriorityPool) to ensure that no vulnerabilities exist.


Conclusion

While there are no glaring vulnerabilities in the code itself, several operational risks exist—particularly around misconfiguration, ownership transfer, and dependency management. Adding more state validations, logging, and fail-safes will improve the robustness of the deployment process.

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.