Division before multiplication could lead to users losing 50% in WithdrawalQueue #67
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
H-02
primary issue
Highest quality submission among a set of duplicates
satisfactory
satisfies C4 submission criteria; eligible for awards
selected for report
This submission will be included/highlighted in the audit report
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/code-423n4/2024-04-gondi/blob/b9863d73c08fcdd2337dc80a8b5e0917e18b036c/src/lib/pools/WithdrawalQueue.sol#L137-L144
Vulnerability details
Impact
In the
_getAvailable()
function, the calculation performs division before multiplication, which could result in precision loss. The consequence is that users may not be able to withdraw the amount they should receive, leaving some funds locked in the WithdrawalQueue.Proof of Concept
Consider the following scenario:
The current calculation will yield
However, the users should actually receive
As shown, the users lose almost 50% of what they should receive.
Tools Used
Manual Review
Recommended Mitigation Steps
Change the order of calculation to multiply before division.
Assessed type
Math
The text was updated successfully, but these errors were encountered: