Closed howlbot-integration[bot] closed 5 months ago
How could they end up being 0 ?
Picodes marked the issue as unsatisfactory: Insufficient proof
Hi @Picodes,
These values can end up being zero if positionSize
is zero for a particular leg.
In the getAmountsMoved
function, positionSize
is used to calculate amount0
and amount1
:
if (tokenId.asset(legIndex) == 0) {
amount0 = positionSize * uint128(tokenId.optionRatio(legIndex));
amount1 = Math.getAmount1ForLiquidity(Math.getLiquidityForAmount0(tickLower, tickUpper, amount0)).toUint128();
} else {
amount1 = positionSize * uint128(tokenId.optionRatio(legIndex));
amount0 = Math.getAmount0ForLiquidity(Math.getLiquidityForAmount1(tickLower, tickUpper, amount1)).toUint128();
}
If positionSize
is zero, amount0
and amount1
will also be zero, regardless of the value of tokenId.asset(legIndex)
. This means that if positionSize
is zero for a particular leg, the corresponding movedRight
, movedLeft
, movedPartnerRight
, or movedPartnerLeft
values in the _computeSpread
function will be zero, potentially leading to notional
or notionalP
being zero.
In your original report, you can't just say "if this variable is zero it reverts". You need to properly show with a credible scenario that this variable can be 0.
@Picodes Yes, noted. I have provided further information in comment to confirm this report.
My point is that I can't correct the judgment based on these comments. PJQA is made to clarify the original report and correct mistakes, not to add new elements
@Picodes Possibility of zero value not mitigated has been confirmed in many prior reports that don't necessarily show how the zero value will happen.. even so PJQA is meant to offer a chance for wardens to justify validity of submissions unless I'm mistaken. I can provide links to the reports. Kindly review this again as the original report is valid.
I can also provide links to reports that judgement of report has changed based on comments. Let me know thanks.
How could they end up being 0 ?
I was also answering your question given the basis of invalidating report was insufficient proof..and I added proof to clarify the original report which includes where the problem code is.
Thanks for your understanding
Regarding other reports, I honestly don't know, but every context is different so let's refer to C4 rules only
Lines of code
https://github.com/code-423n4/2024-06-panoptic/blob/main/contracts/CollateralTracker.sol#L1516
Vulnerability details
Impact
The
_computeSpread
function in theCollateralTracker
contract contains a calculation that may result in a division by zero error if eithernotional
ornotionalP
is zero. This issue can lead to runtime errors, causing the contract to terminate unexpectedly. Such errors can disrupt the collateral tracking process, potentially leading to incorrect collateral calculations and vulnerabilities in the contract.Proof of Concept
Line of Code:
If either
notional
ornotionalP
is zero, the division in theMath.unsafeDivRoundingUp
function will result in a division by zero error, causing the contract execution to fail. This can be demonstrated by settingnotional
ornotionalP
to zero and observing the contract's behavior during execution.Tools Used
Manual
Recommended Mitigation Steps
Check for zero values before performing the division.
Assessed type
Math