In MarketUtils.sol the function sumReturnUint256 take in a uint256 number and an int256 number and returns their sum in uint256 but this function is not properly written as in a situation where the int256 number is more negative than the uint256 number is positive, an underflow will occur reverting the entire transaction.
When checking if a Positions collateral is sufficient the function getMinCollateralFactorForOpenInterest() is used to get the minimum collateral factor, this function calls sumReturnUint256() to return the sum of a uint256 number and an int256 number in uint256
In sumReturnUint256() if b is neagtive, it is converted to a positive uint256 and then subtracted from a.
But in a situation in which the int256 number is more negative than the uint256 number is positive, the function will revert due to underflow.
To explain better,lets take for example
a = 5
b = -7
when sumReturnUint256() is called
-(-7) is done converting b to 7
but then 5-7 is then attempted causing a revert due to underflow.
possible underflow in sumReturnUint256() as the function doesn't account for a situation where after conversion to positive b becomes greater than a
Manual Review
sumReturnUint256() should be corrected to return zero instead, to prevent underflows.
Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelihood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.
There is no real proof, concrete root cause, specific impact, or enough details in those submissions. Examples include: "It could happen" without specifying when, "If this impossible case happens," "Unexpected behavior," etc. Make a Proof of Concept (PoC) using external functions and realistic parameters. Do not test only the internal function where you think you found something.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.