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

rageQuit function can be called when totalStaked is 0 #315

Closed
code423n4 opened this issue Jun 19, 2022 · 1 comment
Closed

rageQuit function can be called when totalStaked is 0 #315

code423n4 opened this issue Jun 19, 2022 · 1 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 sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-06-infinity/blob/main/contracts/staking/InfinityStaker.sol#L193

Vulnerability details

Impact

Users can call rageQuit when there is nothing staked.

Proof of Concept

This part checks if totalStaked is more than and equal to 0.

https://github.com/code-423n4/2022-06-infinity/blob/main/contracts/staking/InfinityStaker.sol#L193

require(totalStaked >= 0, 'nothing staked to rage quit');

totalStaked is uint256, so require check always pass even though totalStaked is 0.

getRageQuitAmounts is used by rageQuit function. Therefore, it is possible that users can call rageQuit function when totalStaked is 0 which is not expected.

Tools Used

static code analysis

Recommended Mitigation Steps

Fix the condition used at the require check. If totalStaked should not be zero, it can simply do like this:

require(totalStaked != 0, 'nothing staked to rage quit');
@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 Jun 19, 2022
code423n4 added a commit that referenced this issue Jun 19, 2022
@nneverlander nneverlander added disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons labels Jul 5, 2022
@HardlyDifficult
Copy link
Collaborator

HardlyDifficult commented Jul 11, 2022

Fair improvement to consider, but no harm was identified. Lowering risk and merging with the warden's QA report #327

@HardlyDifficult HardlyDifficult added 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 and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Jul 11, 2022
This was referenced Jul 11, 2022
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 sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons
Projects
None yet
Development

No branches or pull requests

4 participants