Liquid Staking

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

scripts/prod/1.0.0-metis-staking/1-deploy-rewards-sender.ts

The code looks well-structured, but there are potential vulnerabilities and pitfalls worth noting, especially in the context of security and reliability. Below is a breakdown of possible issues, categorized by risk.


1. Network Switching Risk:

  • Network Switching Without Authentication:

    const response = await axios.post(`http://${host}:1248`, { ... });
    • Issue: There’s no authentication mechanism in the switchNetwork function. If host is improperly validated or exposed to attackers, they could switch the network or spoof responses by controlling the endpoint.

    • Fix: Add authentication (e.g., API keys or JWTs) and ensure the host is properly sanitized before use.

  • Hardcoded Port 1248:
    Using a static port without checks makes the connection predictable and potentially vulnerable to port attacks if exposed to external actors.


2. Unvalidated User Input:

  • host Parameter Validation:

    • Issue: The host value is passed directly into the axios.post call. If it comes from user input or an untrusted source, it could be exploited (e.g., by SSRF attacks). An attacker could trick the system into making unintended requests to other servers.

    Fix: Ensure that host is validated to avoid unwanted URL redirects or SSRF attacks.


3. Error Handling Pitfalls:

  • Potential Blind Spots in Error Handling:

    if (axios.isAxiosError(error)) {
    const errorText = error.response?.data || error.message;
    throw new Error(`Failed to switch network: ${errorText}`);
    } else {
    throw error;
    }
    • Issue: While Axios errors are handled, there could still be edge cases that escape detection (e.g., unexpected errors). Additionally, leaking raw error messages could expose sensitive internal information to external logs.

    Fix: Ensure only sanitized error messages are shown, and consider logging additional error metadata securely.


4. Ethers.js Usage:

  • ZeroAddress Hardcoding:

    router: ethers.ZeroAddress,
    transferInitiator: ethers.ZeroAddress,
    • Issue: Using the zero address (0x00...) without proper validation can introduce issues:

      • If used accidentally, it can result in funds or tokens being irrecoverably sent to a non-existent address.

      • If used as a placeholder, the logic should validate that these addresses are replaced with valid addresses during deployment.

    Fix: Add pre-deployment validation to ensure that these addresses are not the zero address.


5. Potential Reentrancy Risk in deployUpgradeable:

const rewardsSender = await deployUpgradeable('SequencerRewardsCCIPSender', [...]);
  • Issue: Although the deployment logic isn’t shown here, upgradeable contracts require careful handling to avoid reentrancy attacks (especially if proxies are used). Ensure that:

    • State-changing functions are marked as nonReentrant.

    • There are checks-effects-interactions patterns where necessary.


6. Lack of Input Validation in Deployments:

  • Contract Parameters:

    [wstMETIS.name, wstMETIS.symbol, wstMETIS.decimals, 0]
    • Issue: There are no checks on the provided parameters (e.g., name, symbol, decimals). If these parameters are manipulated, unintended behavior could occur. For example, setting decimals incorrectly could lead to rounding or token supply issues.

    Fix: Add validation to ensure that inputs conform to expected formats and ranges.


7. Insecure Handling of Extra Arguments:

extraArgs: '0x',
  • Issue: If extraArgs is used to configure contract behavior, passing it as '0x' could result in either unintended default behaviors or become a vector for malicious parameter injections.

    Fix: Validate and sanitize extraArgs inputs, ensuring only valid parameters are accepted.


8. Hardcoding Chain ID & Destination Selector:

await switchNetwork(1088, '');
destinationChainSelector: '5009297550715157269';
  • Issue: Hardcoding chain IDs and destination selectors makes the code less flexible and harder to maintain. It also increases the chance of errors if the target chain changes or if someone copies the code for another chain and forgets to update these values.

Fix: Consider using environment variables or configuration files for these values.


9. Upgradeability Pitfalls:

  • Upgradeable Contracts and Proxy Management:

    • Upgradeable contracts require careful management to ensure security. If the implementation contract is replaced maliciously, it could lead to unauthorized access or fund loss.
      Fix: Use a proper proxy management pattern with access controls (like OpenZeppelin’s ProxyAdmin).


Summary of Recommendations:

  1. Validate host to prevent SSRF.

  2. Implement authentication for switching networks.

  3. Sanitize error messages to avoid leaking internal details.

  4. Validate non-zero addresses during contract deployment.

  5. Ensure reentrancy protection and input validation for deployable contracts.

  6. Externalize chain IDs and configuration into environment variables.

Addressing these points will enhance the security and robustness of your code.

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.