Submitted by WatchPug
In Collateral, the getter functions getAmountForShares() and getSharesForAmount() is using totalAssets() instead of _strategyController.totalValue(), making the results can be different than the actual shares amount needed to withdraw() a certain amount of _baseToken and the amount of shares expected to get by deposit() a certain amount.
Specifically, totalAssets() includes the extra amount of _baseToken.balanceOf(Collateral).
Collateral.sol#L306-L329
Collateral.sol#L339-L343
Collateral.sol#L137-L148
Given:
totalAssets() returns: 200
getSharesForAmount(100) returns: 50, while withdraw(50) will actual only get: 55.
When Collateral is used by another contract that manages many users funds, and if its using getSharesForAmount() to calculate the amount of shares needed for a certain amount of underlying tokens to be withdrawn.
This issue can potentially cause fund loss to the user of that contract because it will actually send a lesser amount of _baseToken than expected.
Consider changing Collateral.totalValue() to:
ramenforbreakfast (prePO) confirmed and commented:
gzeon (judge) commented:
For this contest, 35 reports were submitted by wardens detailing low risk and non-critical issues. The report highlighted below by defsec received the top score from the judge.
The following wardens also submitted reports: GreyArt, hake, 0xkatana, berndartmueller, cmichel, csanuragjain, IllIllI, rayn, 0x1f8b, 0xDjango, CertoraInc, robee, sorrynotsorry, WatchPug, 0xNazgul, 0xwags, bugwriter001, cccz, Funen, GeekyLumberjack, kenta, kirk-baird, leastwood, minhquanym, peritoflores, remora, Ruhum, saian, samruna, TerrierLover, Kenshin, oyc_109, rfa, and wuwe1.
