-
Notifications
You must be signed in to change notification settings - Fork 7
neumo - If collateral factor is high enough, flutter ends up being out of bounds #889
Comments
Escalate for 10 USDC |
You've created a valid escalation for 10 USDC! To remove the escalation from consideration: Delete your comment. You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final. |
function setFlutterRatios(uint256[] calldata _flutterRatios) public onlyControl {
flutterRatios = _flutterRatios;
} flutterRatios can be adjusted by admin Valid low |
Result: |
Escalations have been resolved successfully! Escalation status:
|
neumo
high
If collateral factor is high enough, flutter ends up being out of bounds
Summary
In
USSDRebalancer
contract, functionSellUSSDBuyCollateral
will revert everytime a rebalance calls it, provided the collateral factor is greater than all the elements of theflutterRatios
array.Vulnerability Detail
Function
SellUSSDBuyCollateral
calculatesflutter
as the lowest index of theflutterRatios
array for which the collateral factor is smaller than the flutter ratio.The problem arises when, if collateral factor is greater than all flutter values, after the loop
flutter = flutterRatios.length
.This
flutter
value is used afterwards here:And here:
As we can see in the tests of the project, the flutterRatios array and the collateral ratios array are set to be of the same length, so if flutter = flutterRatios.length, any call to that index in the
ratios
array will revert with an index out of bounds.Impact
High, when the collateral factor reaches certain level, a rebalance that calls
SellUSSDBuyCollateral
will always revert.Code Snippet
https://github.com/sherlock-audit/2023-05-USSD/blob/main/ussd-contracts/contracts/USSDRebalancer.sol#L178-L184
Tool used
Manual review.
Recommendation
When checking
collateral[i].ratios[flutter]
always check first that flutter is< flutterRatios.length
.The text was updated successfully, but these errors were encountered: