Open sherlock-admin2 opened 10 months ago
Valid issue and I would consider increasing the severity to high. While this is not a risk for the leveraged vault framework (transactions revert inside the time window between fCash maturity and settlement rate initialization), this may cause severe issues for another protocol which relies on the convertToAssets
method as a valuation method.
I believe the proper solution here is to revert
while the settlement rate is not set.
@jeffywu Since it is impossible to know how it will impact other protocols for wrong integrations, I will maintain is medium severity.
The protocol team fixed this issue in PR/commit https://github.com/notional-finance/wrapped-fcash/pull/13.
The Lead Senior Watson signed-off on the fix.
xiaoming90
medium
Unexpected behavior when calling certain ERC4626 functions
Summary
Unexpected behavior could occur when certain ERC4626 functions are called during the time windows when the fCash has matured but is not yet settled.
Vulnerability Detail
When the fCash has matured, the global settlement does not automatically get executed. The global settlement will only be executed when the first account attempts to settle its own account. The code expects the
pr.supplyFactor
to return zero if the global settlement has not been executed yet after maturity.Per the comment at Line 215, the design of the
_getMaturedCashValue
function is that it expects that if fCash has matured AND the fCash has not yet been settled, thepr.supplyFactor
will be zero. In this case, the cash value will be zero.https://github.com/sherlock-audit/2023-12-notional-update-5/blob/main/wrapped-fcash/contracts/wfCashBase.sol#L215
During the time window where the fCash has matured, and none of the accounts triggered an account settlement, the
_getMaturedCashValue
function at Line 33 below will return zero, which will result in thetotalAssets()
function returning zero.https://github.com/sherlock-audit/2023-12-notional-update-5/blob/main/wrapped-fcash/contracts/wfCashERC4626.sol#L33
Impact
The
totalAssets()
function is utilized by key ERC4626 functions within the wrapper, such as the following functions. The side effects of this issue are documented below:convertToAssets
(Impact = returned value is always zero assets regardless of the inputs)convertToAssets
>previewRedeem
(Impact = returned value is always zero assets regardless of the inputs)convertToAssets
>previewRedeem
>maxWithdraw
(Impact = max withdrawal is always zero)convertToShares
(Impact = Division by zero error, Revert)convertToShares
>previewWithdraw
(Impact = Revert)In addition, any external protocol integrating with wfCash will be vulnerable within this time window as an invalid result (zero) is returned, or a revert might occur. For instance, any external protocol that relies on any of the above-affected functions for computing the withdrawal/minting amount or collateral value will be greatly impacted as the value before the maturity might be 10000, but it will temporarily reset to zero during this time window. Attackers could take advantage of this time window to perform malicious actions.
Code Snippet
https://github.com/sherlock-audit/2023-12-notional-update-5/blob/main/wrapped-fcash/contracts/wfCashBase.sol#L215
https://github.com/sherlock-audit/2023-12-notional-update-5/blob/main/wrapped-fcash/contracts/wfCashERC4626.sol#L33
Tool used
Manual Review
Recommendation
Document the unexpected behavior of the affected functions that could occur during the time windows when the fCash has matured but is not yet settled so that anyone who calls these functions is aware of them.