Impossibility to change safeCollateralRatio
The vault's vaultType variable is internal, so the configurator's staticcall to read it reverts, making it impossible to change the safeCollateralRatio. This could become critical when market conditions change, such as a drop in ETH price.
georgypetrov Follow with Kenshin, bart1e and 6 others
Originally disclosed on Code4rena
Submitted by georgypetrov, also found by Kenshin, bart1e, DelerRH, pep7siup, ktg, SpicyMeatball, CrypticShepherd, and LuchoLeonel1
Lines of code
Impact
Because of vaultType variable is internal vaultType staticcall to vaults from the configurator will revert, so it makes it impossible to change safeCollateralRatio. It may be critical when market conditions will change, something happens with ETH.
Proof of Concept
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import "forge-std/Test.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {GovernanceTimelock} from "@lybra/governance/GovernanceTimelock.sol";
import {LybraStETHDepositVault} from "@lybra/pools/LybraStETHVault.sol";
import {Configurator} from "@lybra/configuration/LybraConfigurator.sol";
import {mockEtherPriceOracle} from "@mocks/mockEtherPriceOracle.sol";
import {mockCurve} from "@mocks/mockCurve.sol";
/* remappings used
@lybra=contracts/lybra/
@mocks=contracts/mocks/
*/
contract LybraV2SafeCollateral is Test {
GovernanceTimelock govTimeLock;
mockEtherPriceOracle oracle;
mockCurve curve;
Configurator configurator;
LybraStETHDepositVault stETHVault;
address owner = address(7);
// admins && executers of GovernanceTimelock
address[] govTimelockArr;
IERC20 stETH = IERC20(0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84);
function setUp() public {
vm.startPrank(owner);
oracle = new mockEtherPriceOracle();
govTimelockArr.push(owner);
govTimeLock = new GovernanceTimelock(
1,
govTimelockArr,
govTimelockArr,
owner
);
curve = new mockCurve();
// _dao , _curvePool
configurator = new Configurator(address(govTimeLock), address(curve));
stETHVault = new LybraStETHDepositVault(
address(configurator),
address(stETH),
address(oracle)
);
vm.stopPrank();
}
function testSafeCollateral() public {
vm.startPrank(owner);
configurator.setSafeCollateralRatio(address(stETHVault), 165 * 1e18);
}
}
Tools Used
Foundry
Recommended Mitigation Steps
Change getter function in LybraConfigurator:
interface IVault {
function getVaultType() external view returns (uint8);
}
...
...
if(IVault(pool).getVaultType() == 0) {
Assessed type
DoS
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The vaultType state variable is declared internal instead of exposing a public getter, so the configurator's staticcall to read it reverts.
Impact
The safeCollateralRatio cannot be changed, which may be critical when market conditions change, such as something happening with ETH.
What the attacker needed
Owner or governance role; deployed vault and configurator
The fix
The configurator should call a public getter such as getVaultType() instead of reading the internal variable directly.
How it was found
- Deploy the governance timelock, oracle, curve mock, configurator and stETH vault.
- As the owner, call setSafeCollateralRatio on the configurator for the stETH vault.
- The call reverts because the configurator cannot read the vault's internal vaultType.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A smart contract stores a setting called safeCollateralRatio that controls how much collateral is needed. The admin tool tries to read a value from the vault to check its type, but that value is marked internal, meaning outside contracts cannot read it. The read fails, so the admin can never update the safety ratio.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.