Open code423n4 opened 1 year ago
Picodes marked the issue as primary issue
SantiagoGregory marked the issue as sponsor confirmed
androolloyd marked the issue as sponsor acknowledged
Picodes marked the issue as satisfactory
Picodes marked the issue as selected for report
Lines of code
https://github.com/code-423n4/2023-01-astaria/blob/main/src/PublicVault.sol#L251-L265 https://github.com/code-423n4/2023-01-astaria/blob/main/src/PublicVault.sol#L148-L190 https://github.com/code-423n4/2023-01-astaria/blob/main/src/PublicVault.sol#L148
Vulnerability details
Description
Some tokens take a transfer fee (e.g.
STA
,PAXG
), some do not currently charge a fee but may do so in the future (e.g.USDT
,USDC
).Should a fee-on-transfer token be added to the
PublicVault
, the tokens will be locked in thePublicVault.sol
contract. Depositors will be unable to withdraw their rewards. In the current implementation, it is assumed that the received amount is the same as the transfer amount. However, due to how fee-on-transfer tokens work, much less will be received than what was transferred. As a result, later users may not be able to successfully withdraw their shares, as it may revert at https://github.com/code-423n4/2023-01-astaria/blob/main/src/PublicVault.sol#L148 whenWithdrawProxy
is called due to insufficient balance.Proof of Concept
i.e. Fee-on-transfer scenario: Contract calls transfer from contractA 100 tokens to current contract Current contract thinks it received 100 tokens It updates balances to increase +100 tokens While actually contract received only 90 tokens That breaks whole math for given token
https://github.com/code-423n4/2023-01-astaria/blob/main/src/PublicVault.sol#L251-L265
https://github.com/code-423n4/2023-01-astaria/blob/main/src/PublicVault.sol#L148-L190
These functions inherits functions from the
ERC4626-Cloned.sol
https://github.com/AstariaXYZ/astaria-gpl/blob/4b49fe993d9b807fe68b3421ee7f2fe91267c9ef/src/ERC4626-Cloned.solhttps://github.com/AstariaXYZ/astaria-gpl/blob/4b49fe993d9b807fe68b3421ee7f2fe91267c9ef/src/ERC4626-Cloned.sol#L19-L36
Recommended Mitigation Steps