incorrect check in decoding well data via decodeWellData
can lead to wrong scaling of reserves and wrong calculations
#45
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-17
🤖_09_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-07-basin/blob/7d5aacbb144d0ba0bc358dfde6e0cc913d25310e/src/functions/Stable2.sol#L317
Vulnerability details
Impact
Stable2::decodeWellData
incorrectly assumes the decimal precision ofdecimal1
based on provided value fordecimal0
.If this not the case (i.e. decimal1 != decimal0) then the reserves will be incorrectly scaled and well calculations will be incorrect.Proof of Concept
From the above code snippet, we can see that the value of
decimal0
is used to setdecimal1
. This can be an issue whendecimal0
is 0 butdecimal1
is not ,ordecimal1
is 0 butdecimal0
is not, as token reserves will be incorrectly scaled leading to wrong calculations.Tools Used
Manual Review
Recommended Mitigation Steps
Assessed type
Decimal
The text was updated successfully, but these errors were encountered: