Closed sherlock-admin3 closed 1 month ago
I consider this issue to be invalid:
The issue describes two impacts
For (1), it is intended to round-up. The rounding-direction should always favour the protocol, so it should round-up. Also, the loss of funds to users is very minimal (1 or 2 wei). The loss is the value of extra shares because of rounding up and that value is always less than totalSupply / totalShares
.
If the withdraw function is rounded-down as suggested in mitigation, then protocol is burning less shares, its a loss for the protocol.
For (2), the shown DoS is that superPool cannot remove a pool with liquidity in it
. The PoC test sets the forceRemove
parameter of SuperPool.removePool
to false. If the forceRemove
is set to false then the Pool.withdraw
function is not even called which was the shown root cause.
Also setting forceRemove
to True, the SuperPool will withdraw the full assets and can close the pool.
function removePool(uint256 poolId, bool forceRemove) external onlyOwner {
if (poolCapFor[poolId] == 0) return; // no op if pool is not in queue
uint256 assetsInPool = POOL.getAssetsOf(poolId, address(this));
if (forceRemove && assetsInPool > 0) POOL.withdraw(poolId, assetsInPool, address(this), address(this));
_removePool(poolId);
poolCapFor[poolId] = 0;
emit PoolCapSet(poolId, 0);
}
If forceRemove
is set to false then withdraw
is never called.
uint256 assetsInPool = POOL.getAssetsOf(poolId, address(this));
if (forceRemove && assetsInPool > 0) POOL.withdraw(poolId, assetsInPool, address(this), address(this));
Because rounding-up the shares is intended in withdraw
function, the loss is negligible, and there's no DoS, I consider this issue to be invalid.
Escalate, Per the above comment
Escalate, Per the above comment
You've created a valid escalation!
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.
Additional Input:
is also not compliant with ERC 4626.
Making this statement without any source of truth is questionable. OpenZeppelin's ERC4626 also rounds UP when withdrawing and their implementation is EIP 4626 compliant.
I agree with the escalation.
The protocol rounds up correctly. We can see that OpenZeppelin's ERC4626 also does it this way.
Also, @S3v3ru5 has correctly identified that the PoC test is incorrect, and we have no issue.
Planning to accept the escalation and invalidate the issue.
@cvetanovv I disagree with it, as you can see the pool will be in withdraw queue in SuperPool but withdraw function from SuperPool will fail because the withdraw function will not let the liquidity to be withdrawn in full from underlying pool due to rounding
Agree with the escalation, this should be invalid.
It seems to be a result of iliquidity and not rounding. Additionally the Pool.withdraw
rounding direction is intended to be in favor of the protocol
The sponsor confirms that this is an intended design, and we have no issue here. For this, my decision remains.
My decision to accept the escalation and invalidate the issue remains.
But it can create a situation of DOS if in superPool contract it assumes that underlying pool in withdraw queuw has that much amount of liquidity which can be withdrawn but that transaction reverts due to rounding calculation, that is issue right ?
@Mihir018 We don't have a DoS situation in SuperPool. See this comment: https://github.com/sherlock-audit/2024-08-sentiment-v2-judging/issues/601#issuecomment-2352078735
My decision to accept the escalation and invalidate the issue remains.
Result: Invalid Unique
Darinrikusham
High
Calculation issue will impact in loss in user funds and DOS
Summary
In withdraw function in pool.sol contract while calculating amount of shares it is rounding up which results in loss in user funds and DOS as user will not be able to fully withdraw the deposited assets and Superpool is also not compliant with ERC 4626.
Root Cause
The choice to round up on pool.sol:350 is a mistake as it results in loss of user funds and DOS as user can't withdraw the full asset amount. It also affects withdraw function in SuperPool.sol as underneath it calls withdraw function on pool.sol
Internal pre-conditions
It will happen in all scenarios after interest is accrued and peg is not 1:1 between assets and shares.
External pre-conditions
No response
Attack Path
Impact
The user loose a part of deposited asset amount and can't withdraw the deposited amount fully causing withdraw function unusable to withdraw all assets and also cause the same DOS issue in superPool withdraw function.
PoC
In Pool.t.sol
In Superpool.t.sol
Mitigation
Changing
Math.Rounding.Up
toMat.Rounding.Down
in Pool.sol:350 solves the issue.