Part 2

Zaros
PerpetualsDEXFoundrySolidity
70,000 USDC
View results
Submission Details
Severity: low
Invalid

Potential DoS during initialization of dex-adapters

Summary

During initialization of dex-adapters, the contract is vulnerable to a denial-of-service (DoS) due to incorrectly handled access control. This potentially blocks the deployer from initializing these contracts when he is not the one passing his own address as owner.

Vulnerability Details

The initialize() functions in CurveAdapter, UniswapV2Adapter and UniswapV3dapter all take owner address as an input parameter. This may mean that the protocol intends to allow any deployer to be in a position to set any other protocol official other than themselves as the owner of these contracts during initialization.

Consider CurveAdapter:initialize():

function initialize(
address owner,
address _curveStrategyRouter,
uint256 _slippageToleranceBps
)
external
initializer
{
// initialize the owner
>> __BaseAdapter_init(owner, _slippageToleranceBps);
// set the Curve Swap Strategy Router
>> setCurveStrategyRouter(_curveStrategyRouter);
}

Issue scenario:

Let's use the common function call in all of them: __BaseAdapter_init():

  • Alice (deployer) calls initialize() on CurveAdapter passing Bob's address (another admin) as owner.

function __BaseAdapter_init(address owner, uint256 _slippageToleranceBps) public initializer {
// initialize the owner
>> __Ownable_init(owner);
// set the slippage tolerance
>> setSlippageTolerance(_slippageToleranceBps); //! Potential initialization failure
}
  • This internal function takes the provided owner adress and passes it into __Ownable_init() which basically sets this address as the contract owner. Immediately, it invokes setSlippageTolerance():

>> function setSlippageTolerance(uint256 newSlippageTolerance) public onlyOwner {
//...
slippageToleranceBps = newSlippageTolerance;
//...
}
  • Notice that this function has the onlyOwner modifier which requires invokation only by the current contract owner.

  • However, Alice is the caller but not the owner, Bob is. This initialization fails.

Impact

The current implementation will completely block the initialization flow when trying to set a different owner disrupting protocol deployment and setup processes.

Tools Used

Manual Review

Recommendations

If the intention of the protocol is to allow any deployer to set a diffrent address as owner, then create internal functions for the above owner controlled functions and invoke those created internal functions during initialization:
These owner controlled functions include:

Updates

Lead Judging Commences

inallhonesty Lead Judge 6 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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