-
Notifications
You must be signed in to change notification settings - Fork 7
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
_amountOut
is representing assets and shares at the same time in the liquidate
function
#427
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
H-03
primary issue
Highest quality submission among a set of duplicates
satisfactory
satisfies C4 submission criteria; eligible for awards
selected for report
This submission will be included/highlighted in the audit report
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Comments
code423n4
added
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
labels
Jul 14, 2023
Picodes marked the issue as duplicate of #5 |
Picodes marked the issue as selected for report |
c4-judge
added
primary issue
Highest quality submission among a set of duplicates
selected for report
This submission will be included/highlighted in the audit report
labels
Jul 14, 2023
This was referenced Jul 16, 2023
asselstine marked the issue as sponsor confirmed |
c4-sponsor
added
the
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
label
Jul 20, 2023
Fixed in this PR: GenerationSoftware/pt-v5-vault#6 |
Picodes marked the issue as satisfactory |
c4-judge
added
the
satisfactory
satisfies C4 submission criteria; eligible for awards
label
Aug 5, 2023
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
H-03
primary issue
Highest quality submission among a set of duplicates
satisfactory
satisfies C4 submission criteria; eligible for awards
selected for report
This submission will be included/highlighted in the audit report
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/GenerationSoftware/pt-v5-vault/blob/b1deb5d494c25f885c34c83f014c8a855c5e2749/src/Vault.sol#L550-L587
Vulnerability details
Impact
In the
liquidate
function from theVault
contract, the input argument_amountOut
is used as if it was representing a value of asset amount and share amount at the same time which is impossible a there a conversion rate between them, this error will makeliquidate
function behave in an expected manner, not the one that was intended.Proof of Concept
The issue is occurring in the
liquidate
function below :As you can see from the code above, the value of the argument
_amountOut
is used multiple times in the function logic and each time it is representing either an asset amount or a share amount which is impossible as there a conversion formula used to transform asset amount into share amount (and inversely) with the function_convertToShares
(or_convertToAssets
).From the function comments i couldn't figure out what the value of
_amountOut
actually represents, but because there is also another argument given to theliquidate
function which is_tokenOut == address(this)
, I'm supposing that_amountOut
is representing a share amount which will mean that all the instances highlighted in the code above when_amountOut
is considered as an asset amount are wrong.And before comparing
_amountOut
to the asset amount values :_vaultAssets
and_liquidableYield
, its value should be converted to an asset amount with the function_convertToAssets
.This issue will cause problems for the protocol working as the
liquidate
function logic will not behave as expected (because it's comparing values that represents different things).** Note : if
_amountOut
is actually representing an asset amount (not a share amount as i supposed), the issue is still valid because_amountOut
is also used as being a share amount inside theliquidate
function, in that case it should first be converted to a share amount with_convertToShares
in order to get the correct behavior of theliquidate
function.Tools Used
Manual review
Recommended Mitigation Steps
To solve this issue i recommend to first convert the value of
_amountOut
in theliquidate
function to an asset amount and store it in a local variable_amountOutToAsset
, and in the function logic use the correct variable (either_amountOut
or_amountOutToAsset
) when interacting with a share amount or an asset amount.Assessed type
Error
The text was updated successfully, but these errors were encountered: