Platform: Code4rena
Start Date: 23/06/2023
Pot Size: $60,500 USDC
Total HM: 31
Participants: 132
Period: 10 days
Judge: 0xean
Total Solo HM: 10
Id: 254
League: ETH
Rank: 65/132
Findings: 1
Award: $84.36
🌟 Selected for report: 0
🚀 Solo Findings: 0
84.3563 USDC - $84.36
https://github.com/code-423n4/2023-06-lybra/blob/main/contracts/lybra/configuration/LybraConfigurator.sol#L127 https://github.com/code-423n4/2023-06-lybra/blob/main/contracts/lybra/configuration/LybraConfigurator.sol#L198-L205 https://github.com/code-423n4/2023-06-lybra/blob/main/contracts/lybra/configuration/LybraConfigurator.sol#L331-L336 https://github.com/code-423n4/2023-06-lybra/blob/main/contracts/lybra/configuration/LybraConfigurator.sol#L338-L341
Wrong if clause allows vaultBadCollateralRatio value that is larger than vaultSafeCollateralRatio value to be set
vaultBadCollateralRatio should always less than vaultSafeCollateralRatio
As shown in the code, vaultBadCollateralRatio = vaultSafeCollateralRatio - 10 (See LybraConfigurator.sol#L338-L341 and LybraConfigurator.sol#L198-L205)
However, badCollateralRatio is allowed to be reset with a wrong condition rule (See the following code => LybraConfigurator.sol#L126-L130)
function setBadCollateralRatio(address pool, uint256 newRatio) external onlyRole(DAO) { require(newRatio >= 130 * 1e18 && newRatio <= 150 * 1e18 && newRatio <= vaultSafeCollateralRatio[pool] + 1e19, "LNA"); // @audit-info WRONG! vaultBadCollateralRatio[pool] = newRatio; emit SafeCollateralRatioChanged(pool, newRatio); }
where new badCollateralRatio can be larger than vaultSafeCollateralRatio by at most 10 (Which is wrong)
Manual
Change LybraConfigurator#setBadCollateralRatio
function setBadCollateralRatio(address pool, uint256 newRatio) external onlyRole(DAO) { --- require(newRatio >= 130 * 1e18 && newRatio <= 150 * 1e18 && newRatio <= vaultSafeCollateralRatio[pool] + 1e19, "LNA"); //@audit +++ require(newRatio >= 130 * 1e18 && newRatio <= 150 * 1e18 && newRatio <= vaultSafeCollateralRatio[pool] - 1e19, "LNA"); //@audit vaultBadCollateralRatio[pool] = newRatio; emit SafeCollateralRatioChanged(pool, newRatio); }
Invalid Validation
#0 - c4-pre-sort
2023-07-08T21:41:02Z
JeffCX marked the issue as duplicate of #3
#1 - c4-judge
2023-07-28T15:44:48Z
0xean marked the issue as satisfactory