Closed c4-judge closed 4 months ago
alex-ppg marked the issue as duplicate of #18
alex-ppg marked the issue as satisfactory
alex-ppg marked the issue as partial-75
alex-ppg marked the issue as partial-50
A penalty of 25% has been applied due to a misjudged severity of low-risk, and a further penalty of 25% has been applied due to not properly elaborating on the impact related to post-operation checks.
alex-ppg changed the severity to 2 (Med Risk)
Judge has assessed an item in Issue #48 as 3 risk. The relevant finding follows:
[QA-02] False comparison logic in
_doCheckValueType
leading to incorrect post-operation checksImpact
The incorrect comparison logic in the
_doCheckValueType
function can lead to incorrect validation of post-operation checks. This will result in the ptotocol not properly verifying the expected conditions, thereby, allowing operations to proceed when they should not, or failing valid operations.Proof of Concept
The
_doCheckValueType
function is intended to check if a value meets certain conditions based on the operator provided. However, there is a mistake in the comparison logic for thegte
andlte
operators.Look at this part of the code: https://github.com/code-423n4/2024-06-badger/blob/9173558ee1ac8a78a7ae0a39b97b50ff0dd9e0f8/ebtc-protocol/packages/contracts/contracts/LeverageMacroBase.sol#L277-L290
The problem here is with the
gte
andlte
checks. Thegte
(greater than or equal to) check should ensure thatvalueToCheck
is greater than or equal tocheck.value
, and thelte
(less than or equal to) check should ensure thatvalueToCheck
is less than or equal tocheck.value
. However, the current implementation does the opposite.Recommended Mitigation Steps
The comparison logic should be corrected to ensure that the
gte
andlte
checks are performed correctly: