position.update fees operations must be in unchecked #69
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-143
🤖_54_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
sufficient quality report
This report is of sufficient quality
upgraded by judge
Original issue severity upgraded from QA/Gas by judge
Lines of code
https://github.com/code-423n4/2024-08-superposition/blob/4528c9d2dbe1550d2660dac903a8246076044905/pkg/seawater/src/position.rs#L43-L66
Vulnerability details
Impact
overflow
/underflow
when updating the position fees is prevented, which may give wrong values.Proof of Concept
When the position is updated,
owed_fees
are updated, but all operations (add and subtract) use functions that preventoverflow
/underflow
(egchecked_sub
,wrapping_add
).position.rs#L43-L66
https://docs.rs/alloy-primitives/0.7.6/alloy_primitives/aliases/type.U256.html#method.checked_sub
But this is not the case, how this is done in the
Uniswap
’sPosition
library, there all these operations are in anunchecked
block, sinceoverflow
andunderflow
should not prevent these operations and are expected.https://github.com/Uniswap/v3-core/blob/6562c52e8f75f0c10f9deaf44861847585fc8129/contracts/libraries/Position.sol#L66-L91
Tools Used
Manual Review
Recommended Mitigation Steps
Move all these operations in
unsafe
/unchecked
block.Assessed type
Math
The text was updated successfully, but these errors were encountered: