Summary
A critical bug has been identified in the AaveDIVAWrapper contract, where the constructor parameters are passed in an incorrect order to the AaveDIVAWrapperCore base contract. This misconfiguration leads to improper initialization of key contract addresses, resulting in potential operational failures and security vulnerabilities.
Vulnerability Details
The parameters aaveV3Pool, diva are passed in the wrong order to the AaveDIVAWrapperCore constructor, which expects the order as diva, aaveV3Pool, owner.
constructor(address _aaveV3Pool, address _diva, address _owner) AaveDIVAWrapperCore(_aaveV3Pool, _diva, _owner) {}
constructor(address diva_, address aaveV3Pool_, address owner_) Ownable(owner_) {
Impact
The contract will incorrectly assign the _aaveV3Pool, _diva, addresses, leading to erroneous interactions with external systems.
Functions that depend on these addresses may fail to execute as expected, causing disruptions in contract functionality.
Example Of DOS in `AaveDIVAWrapper::registerCollateralToken` :
Owner call `AaveDIVAWrapper::registerCollateralToken`
And This call `AaveDIVAWrapperCore::_registerCollateralToken`
And This call `_diva::getReserveData` as not expected
`getReserveData` function exist in `_aaveV3pool`
pragma solidity ^0.8.26;
import "forge-std/Test.sol";
import {IAaveDIVAWrapper} from "../src/interfaces/IAaveDIVAWrapper.sol";
import {IAave} from "../src/interfaces/IAave.sol";
import {IDIVA} from "../src/interfaces/IDIVA.sol";
import "../src/AaveDIVAWrapper.sol";
import "../src/interfaces/IDIVA.sol";
import "lib/openzeppelin-contracts/contracts/interfaces/IERC20Metadata.sol";
interface IUSDC {
function approve(address spender, uint256 amount) external;
function transfer(address recipient, uint256 amount) external;
function balanceOf(address) external view returns (uint256);
function transferFrom(address sender, address recipient, uint256 amount) external;
function decimals() external view returns (uint8);
}
contract AaveDIVAWrapperTest is Test {
AaveDIVAWrapperCore wrapper;
address trader = address(0x4D8336bDa6C11BD2a805C291Ec719BaeDD10AcB9);
address shortRecipient;
address longRecipient;
bytes32 poolId;
IAave _aavePool = IAave(0x794a61358D6845594F94dc1DB02A252b5b4814aD);
IDIVA _diva = IDIVA(0x2C9c47E7d254e493f02acfB410864b9a86c28e1D);
IUSDC USDC = IUSDC(0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359);
function setUp() public {
wrapper = new AaveDIVAWrapper(address(_aavePool),address(_diva),address(this));
shortRecipient = address(0x1);
longRecipient = address(0x2);
wrapper.registerCollateralToken(address(USDC));
[staticcall]
}
* Root Cause:
* The incorrect constructor order leads to `_diva` pointing to `_aavePool`, causing
* function calls meant for DIVA to fail and block further operations.
Tools Used
Manuial Review
Foundry Framework
Recommendations
- constructor(address _aaveV3Pool, address _diva, address _owner) AaveDIVAWrapperCore(_aaveV3Pool, _diva, _owner) {}
+ constructor(address _aaveV3Pool, address _diva, address _owner) AaveDIVAWrapperCore(_diva , _aaveV3Pool, _owner) {}