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

processWithdrawals maxWithdrawalProcesses is verified incorrectly #21

Closed
code423n4 opened this issue Feb 18, 2022 · 2 comments
Closed
Labels
bug Something isn't working disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) duplicate This issue or pull request already exists QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax resolved Finding has been patched by sponsor (sponsor pls link to PR containing fix) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-02-hubble/blob/main/contracts/VUSD.sol#L57

Vulnerability details

Impact

Contract can go out of gas since contract will try to run withdrawal over and above maxWithdrawalProcesses limit

Proof of Concept

  1. The processWithdrawals function at VUSD.sol#L53 is not imposing checks on maxWithdrawalProcesses correctly

  2. Currently processWithdrawals will run for maxWithdrawalProcesses+1 so there will be one extra run which could cause undesired problems like Out of Gas

  3. Assume maxWithdrawalProcesses was set to 1 and processWithdrawals is called

  4. Since both start and i are 0 so (i - start) <= maxWithdrawalProcesses becomes 0-0<=1 which is true

  5. After the loop completes i becomes 1, so (i - start) <= maxWithdrawalProcesses becomes 1-0<=1 which is again true. This means withdrawal will again run for second time which is incorrect since withdrawal was only allowed once

Recommended Mitigation Steps

Change the below while condition to (= removed):

while (i < withdrawals.length && (i - start) < maxWithdrawalProcesses)
@code423n4 code423n4 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels Feb 18, 2022
code423n4 added a commit that referenced this issue Feb 18, 2022
@atvanguard atvanguard added disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") labels Feb 24, 2022
@atvanguard
Copy link
Collaborator

Not leading to any kind of broken functionality so would classify as 1.

This was referenced Feb 26, 2022
@atvanguard atvanguard reopened this Mar 1, 2022
@atvanguard atvanguard added the resolved Finding has been patched by sponsor (sponsor pls link to PR containing fix) label Mar 1, 2022
@JasoonS JasoonS added QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Mar 6, 2022
@JeeberC4 JeeberC4 added the duplicate This issue or pull request already exists label Mar 24, 2022
@JeeberC4
Copy link

Grouping with warden's QA report #19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) duplicate This issue or pull request already exists QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax resolved Finding has been patched by sponsor (sponsor pls link to PR containing fix) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Projects
None yet
Development

No branches or pull requests

4 participants