Stratax Contracts

First Flight #57
Beginner FriendlyDeFi
100 EXP
Submission Details
Impact: high
Likelihood: high

Attacker can take ownership of leveraged position contract

Author Revealed upon completion

Missing initializer protection allows attackers to overtake the leveraged position contract of any user

Description

  • Normal behavior - User deploys new Stratax contract, initialize it, starts creating leveraged positions etc..

  • Issue - Constructor is empty and owner as well as other critical params are set in the initialize function which has no protection and can be called by a malicious user

// //@audit can be frontran | can be initialized with malicious params
@> function initialize(
address _aavePool,
address _aaveDataProvider,
address _oneInchRouter,
address _usdc,
address _strataxOracle
) external initializer {
aavePool = IPool(_aavePool);
aaveDataProvider = IProtocolDataProvider(_aaveDataProvider);
oneInchRouter = IAggregationRouter(_oneInchRouter);
USDC = _usdc;
strataxOracle = _strataxOracle;
owner = msg.sender;
flashLoanFeeBps = 9; // Default 0.09% Aave flash loan fee
}

Risk

Likelihood:

  • High: Everyone can frontrun the actual owner's tx to initialize the Stratax contract

Impact:

  • Impact - Users cannot create leveraged positions since they won't be the owners

  • Impact - Malicious oracle registered

  • Impact - Random address set for aave pool

  • Impact - Random address set for 1inch router

  • Impact - Random address for aave data provider

Proof of Concept

  1. Bob wants to create a leverage position and firstly deploys a new Stratax contract for that purpose

  2. Since this happens through a proxy , the Stratax.sol is an implementation contract and has initialize

  3. The contract initialization has no protection and constructor is missing _disableInitializers()

  4. Attacker frontruns user's initalization and overtakes the contract

Recommended Mitigation

  1. Update the constructor to have _disableInitializers()

  2. Implement access control

- remove this code
+ add this code

Support

FAQs

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

Give us feedback!