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

Assets are not converted to shares when calculating fees #128

Closed
code423n4 opened this issue Jul 12, 2023 · 4 comments
Closed

Assets are not converted to shares when calculating fees #128

code423n4 opened this issue Jul 12, 2023 · 4 comments
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working duplicate-427 partial-50 Incomplete articulation of vulnerability; eligible for partial credit only (50%)

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/GenerationSoftware/pt-v5-vault/blob/b1deb5d494c25f885c34c83f014c8a855c5e2749/src/Vault.sol#L572-L576

Vulnerability details

Impact

Unable to calculate cost correctly

Proof of Concept

The call path to get the balance

_liquidatableBalanceOf->availableYieldBalance

analyze

Through availableYieldBalance, we know that what is returned is assert not shares
Through mintYieldFee, _increaseYieldFeeBalance we know that _yieldFeeTotalSupply is shares,and the parameter that _increaseYieldFeeBalance needs to pass is shares

So the assert is missing here and converted to shares

Tools Used

manual review

Recommended Mitigation Steps

Convert assert to shares by _convertToShares

if (_yieldFeePercentage != 0) {
  _increaseYieldFeeBalance(
    _convertToShares(
      (_amountOut * FEE_PRECISION) / (FEE_PRECISION - _yieldFeePercentage) - _amountOut, 
      Math.Rounding.Down
   )
  );
}

Assessed type

Error

@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Jul 12, 2023
code423n4 added a commit that referenced this issue Jul 12, 2023
@c4-judge
Copy link
Contributor

Picodes marked the issue as duplicate of #427

@c4-judge
Copy link
Contributor

c4-judge commented Aug 5, 2023

Picodes marked the issue as satisfactory

@c4-judge c4-judge added the satisfactory satisfies C4 submission criteria; eligible for awards label Aug 5, 2023
@c4-judge
Copy link
Contributor

c4-judge commented Aug 5, 2023

Picodes marked the issue as partial-50

@c4-judge c4-judge added partial-50 Incomplete articulation of vulnerability; eligible for partial credit only (50%) and removed satisfactory satisfies C4 submission criteria; eligible for awards labels Aug 5, 2023
@Picodes
Copy link

Picodes commented Aug 5, 2023

Partial credit due to the report's low quality

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-427 partial-50 Incomplete articulation of vulnerability; eligible for partial credit only (50%)
Projects
None yet
Development

No branches or pull requests

3 participants