Open hats-bug-reporter[bot] opened 1 year ago
We're not following the ERC-4626 standard here, except we use some of the function names from there.
Hi @tsudmi I agree, There are no strict requirements to be EIP-4626 compliant hence the low. However, it's in terms of liquidity tokens and Vault always takes a bit less. ensuring it remains secure and doesn't run out of tokens is what the revised code provides.
Github username: @turvec Submission hash (on-chain): 0x392287e70d2ea5e3d056d33b89cef08d00f2c6d6b270fc5c766c401f0394d11d Severity: low
Description: Description\ sharesToBurn in _redeemOsToken should round up but didn't which favor the users and not the vault itself in both redeemOsToken and liquidateOsToken calls, causing VaultOsToken.sol to not be ERC4626-compliant
Attack Scenario\
Attachments
according to EIP-4626- Vault, implementers should be aware of the need for specific, ๐จ๐ฉ๐ฉ๐จ๐ฌ๐ข๐ง๐ ๐ซ๐จ๐ฎ๐ง๐๐ข๐ง๐ ๐๐ข๐ซ๐๐๐ญ๐ข๐จ๐ง๐ฌ across the different mutable and view methods, as it is considered most secure to favor the Vault itself during calculations over its users:
If itโs calculating how many shares to issue to a user for a certain amount of the underlying tokens they provide or itโs determining the amount of the underlying tokens to transfer to them for returning a certain amount of shares, it should ๐ซ๐จ๐ฎ๐ง๐ ๐๐จ๐ฐ๐ง.
If itโs calculating the amount of shares a user has to supply to receive a given amount of the underlying tokens or itโs calculating the amount of underlying tokens a user has to provide to receive a certain amount of shares, it should ๐ซ๐จ๐ฎ๐ง๐ ๐ฎ๐ฉ.
https://eips.ethereum.org/EIPS/eip-4626 https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/extensions/ERC4626.sol#L229
However in the implementation of _redeemOsToken() which is called in both redeemOsToken and liquidateOsToken.
the function calculates the user shares to burn but instead of using the internal _convertToShares, it call the public convertToShares() which Rounds Down by default
and then burn user shares using the Rounded Down value
An easy fix is to change this line of code:
to this: