DeFiFoundry
60,000 USDC
View results
Submission Details
Severity: high
Invalid

Initialization functions can be front-run

Summary

Several initialization functions are vulnerable to front-running attacks, which could lead to malicious actors improperly initializing the contracts with harmful values.

Vulnerability Details

Description

The initialize function in the UpgradeBranch.sol, MarketOrderKeeper.sol and LiquidationKeeper.sol contracts can be front-run, allowing an attacker to initialize the contract with malicious values.

UpgradeBranch.sol

Code Snippet

function initialize(address owner) external initializer {
__Ownable_init(owner);
}

MarketOrderKeeper.sol

Code Snippet

function initialize(
address owner,
IPerpsEngine perpsEngine,
uint128 marketId,
string calldata streamId
) external initializer {
__BaseKeeper_init(owner);
...
}

LiquidationKeeper.sol

Code Snippet

function initialize(address owner, IPerpsEngine perpsEngine) external initializer {
__BaseKeeper_init(owner);
...
}

Impact

  • UpgradeBranch: An attacker could front-run the initialization and set their own address as the owner, gaining control over the contract.

  • MarketOrderKeeper: An attacker could front-run the initialization and set their own address as the owner, gaining control over the contract and also can set invalid or malicious values for the parameters, disrupting the contract's functionality.

  • LiquidationKeeper: An attacker could front-run the initialization and set their own address as the owner, gaining control over the contract and also can set an invalid or malicious address for the perpsEngine parameter, causing the contract to malfunction.

Tools Used

  • manual review

Recommendations

  • ** Factory Pattern**: Consider using a factory contract to deploy and initialize contracts in one transaction, preventing front-running.

  • Deployment Scripts: Ensure deployment scripts have robust protections against front-running attacks.

Updates

Lead Judging Commences

inallhonesty Lead Judge
about 1 year ago
inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.