Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stable2::decodeWellData() - Incorrect check leads to return of wrong decimal precision of decimal1 inside decimals array #33

Closed
howlbot-integration bot opened this issue Aug 10, 2024 · 2 comments
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

Comments

@howlbot-integration
Copy link

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 and decimal1 == 0 then here decimal array will contain decimal1 = 0 but in actual it should assume decimal1 as 18 decimals and set decimal1 = 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

@howlbot-integration howlbot-integration bot added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value 🤖_09_group AI based duplicate group recommendation bug Something isn't working duplicate-17 edited-by-warden sufficient quality report This report is of sufficient quality labels Aug 10, 2024
howlbot-integration bot added a commit that referenced this issue Aug 10, 2024
@c4-judge
Copy link
Contributor

alex-ppg changed the severity to 3 (High Risk)

@c4-judge c4-judge added 3 (High Risk) Assets can be stolen/lost/compromised directly upgraded by judge Original issue severity upgraded from QA/Gas by judge satisfactory satisfies C4 submission criteria; eligible for awards and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Aug 21, 2024
@c4-judge
Copy link
Contributor

alex-ppg marked the issue as satisfactory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

1 participant