-
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
IF THE UNDERLYING ASSET IS A FEE ON TRANSFER TOKEN IT COULD BREAK THE INTERNAL ACCOUNTING OF THE VAULT #470
Comments
Picodes marked the issue as primary issue |
asselstine marked the issue as sponsor confirmed |
Picodes marked the issue as satisfactory |
Picodes marked the issue as selected for report |
Out of scope per the automated report: https://gist.github.com/itsmetechjay/e7fd03943bbacff1984a33b9f89c4149 (MEDIUM-4) |
Picodes marked the issue as unsatisfactory: |
@Picodes, The fee on transfer token vulnerability described in this issue (#470) is related to the token transfers happening in the The |
Indeed. The automated report didn't properly flag that |
Picodes marked the issue as selected for report |
Picodes marked the issue as satisfactory |
Lines of code
https://github.com/GenerationSoftware/pt-v5-vault/blob/b1deb5d494c25f885c34c83f014c8a855c5e2749/src/Vault.sol#L951-L956
https://github.com/GenerationSoftware/pt-v5-vault/blob/b1deb5d494c25f885c34c83f014c8a855c5e2749/src/Vault.sol#L959
https://github.com/GenerationSoftware/pt-v5-vault/blob/b1deb5d494c25f885c34c83f014c8a855c5e2749/src/Vault.sol#L1026-L1027
Vulnerability details
Impact
The
Vault._deposit
function is used by the users to deposit_assets
to the vault and mint vault shares to therecipient
address. The amount of_assets
are transferred to theVault
as follows:The
Vault.deposit
function uses this_assets
amount to calculate the number ofshares
to be minted to the_recipient
address.The issue here is if the underlying
_asset
is a fee on transfer token then the actual received amount to the vault will be less than what is referred in theVault.deposit
function_assets
input parameter. But the shares to mint is calculated using the entire_assets
amount.This issue could be further aggravated since the
_asset
is againdeposited
to the_yieldVault
and when needing to be redeemed will bewithdrawn
from the_yieldVault
as well. These operations will again charge a fee if the_asset
is a fee on transfer token. Hence the actual left_asset
amount for particular user will be less than the amount he initially transferred in.Hence when the user
redeems
the minted shares back to the_assets
, the contract will not have enough assets to transfer to theredeemer
thus reverting the transaction.Proof of Concept
https://github.com/GenerationSoftware/pt-v5-vault/blob/b1deb5d494c25f885c34c83f014c8a855c5e2749/src/Vault.sol#L951-L956
https://github.com/GenerationSoftware/pt-v5-vault/blob/b1deb5d494c25f885c34c83f014c8a855c5e2749/src/Vault.sol#L959
https://github.com/GenerationSoftware/pt-v5-vault/blob/b1deb5d494c25f885c34c83f014c8a855c5e2749/src/Vault.sol#L1026-L1027
Tools Used
Manual Review and VSCode
Recommended Mitigation Steps
Hence it is recommended to compute the
_assets
amount balance of the contract before and after thesafeTransferFrom
call and get the difference between the two as the actually transferred amount to theVault
. Then this actually transferred amount can be converted to shares and mint the correct amount of shares to therecipient
.Assessed type
Other
The text was updated successfully, but these errors were encountered: