Stable2::decodeWellData() - Incorrect check leads to return of wrong decimal precision of decimal1 inside decimals array #33
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-17
edited-by-warden
🤖_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/main/src/functions/Stable2.sol#L317-L319
Vulnerability details
Impact
On decoding the encoded well data in Stable2::decodeWellData() decimals array will be returned containing values of decimal0 and decimal1 but within this function when abi.decode() returns any of these value as 0 then 18 decimals should be assumed and set before returning array but in this case due to incorrect check decimals array is being returned with
decimal1 = 0
, due to this when this array used in other functions for scaling reserves by precision then it will scale reserves[1] with wrong decimal precision.Proof of Concept
// if well data returns 0, assume 18 decimals.
if (decimal0 == 0) {
decimal0 = 18;
}
if (decimal0 == 0) { // @ audit - wrong check
decimal1 = 18;
}
Here in Stable2::decodeWellData() if
decimal0 != 0
anddecimal1 == 0
then here decimal array will containdecimal1 = 0
but in actual it should assume decimal1 as 18 decimals and setdecimal1 = 18
before returning decimals array.Tools Used
Manual review
Recommended Mitigation Steps
// if well data returns 0, assume 18 decimals.
if (decimal0 == 0) {
decimal0 = 18;
}
if (decimal1 == 0) { // @ correct
decimal1 = 18;
}
Assessed type
Decimal
The text was updated successfully, but these errors were encountered: