Open sherlock-admin4 opened 5 months ago
1 comment(s) were left on this issue during the judging contest.
infect3d commented:
if
totalAssets
is 0 the first if statement will be executed thus no revert
Valid medium since it was mentioned as:
Is the codebase expected to comply with any EIPs? Can there be/are there any deviations from the specification? PrizeVaults are expected to strictly comply with the ERC4626 standard.
Sherlock rules states
The protocol team can use the README (and only the README) to define language that indicates the codebase's restrictions and/or expected functionality. Issues that break these statements, irrespective of whether the impact is low/unknown, will be assigned Medium severity
@nevillehuang @WangSecurity I think you didn't take my judging comment into consideration, sorry for acting so late.
If totalAssets == 0
, this means totalDebt == 0
too as:
totalAssets > 0
TotalAssets > TotalDebt
during the existence of the vaultshares (debt) burned > asset withdrawn
, until debt = assets
totalAssets == 0
, then totalDebt == 0
tooHence, this is the case if (_totalAssets >= _totalDebt)
that is executed, and not the else
case, so no division by 0 here.
The only case where this could happen is a yield vault being hacked and fully withdrawn from its asset, and the yield buffer of the prize vault fully emptied If this cannot happen in normal circonstances (yield vault compliant, so no way to get hacked) then we should consider this case cannot happen, so the function cannot revert.
@10xhash FYI
The protocol team fixed this issue in the following PRs/commits: https://github.com/GenerationSoftware/pt-v5-vault/pull/112
Fixed Now maxRedeem returns 0 instead of reverting
The Lead Senior Watson signed off on the fix.
hash
medium
maxRedeem
doesn't comply with ERC-4626Summary
maxRedeem
function reverts due to division by 0 and hence doesn't comply with ERC4626Vulnerability Detail
The contract's
maxRedeem
function doesn't comply with ERC-4626 which is a mentioned requirement. According to the specification,MUST NOT revert.
The
maxRedeem
function will revert in case the totalAsset amount is 0 due to a divison by 0link
link
POC
Impact
Failure to comply with the specification which is a mentioned necessity
Code Snippet
Tool used
Manual Review
Recommendation
Handle the
_totalAssets == 0
condition