-
Notifications
You must be signed in to change notification settings - Fork 0
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
AccountingManager
contract's previewDeposit
, previewMint
, previewWithdraw
, and previewRedeem
functions are not compliant with EIP-4626 standard
#1522
Comments
DadeKuma marked the issue as duplicate of #136 |
DadeKuma marked the issue as sufficient quality report |
gzeon-c4 changed the severity to QA (Quality Assurance) |
gzeon-c4 marked the issue as grade-c |
This previously downgraded issue has been upgraded by gzeon-c4 |
gzeon-c4 marked the issue as partial-50 |
gzeon-c4 marked the issue as not a duplicate |
gzeon-c4 marked the issue as primary issue |
gzeon-c4 marked the issue as satisfactory |
gzeon-c4 marked the issue as selected for report |
Lines of code
https://github.com/code-423n4/2024-04-noya/blob/cc3854f634a72bd4a8b597021887088ca2d6d29f/contracts/accountingManager/AccountingManager.sol#L693-L707
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/extensions/ERC4626.sol#L151-L168
Vulnerability details
Impact
The
AccountingManager
contract'sdeposit(uint256 assets, address receiver)
,mint(uint256 shares, address receiver)
,withdraw(uint256 assets, address receiver, address owner)
, andredeem(uint256 shares, address receiver, address shareOwner)
functions below always revert.https://github.com/code-423n4/2024-04-noya/blob/cc3854f634a72bd4a8b597021887088ca2d6d29f/contracts/accountingManager/AccountingManager.sol#L693-L707
According to https://eips.ethereum.org/EIPS/eip-4626:
previewDeposit
MUST return as close to and no more than the exact amount of Vault shares that would be minted in a ``deposit`` call in the same transaction
andMAY revert due to other conditions that would also cause ``deposit`` to revert
;previewMint
MUST return as close to and no fewer than the exact amount of assets that would be deposited in a ``mint`` call in the same transaction
andMAY revert due to other conditions that would also cause ``mint`` to revert
;previewWithdraw
MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a ``withdraw`` call in the same transaction
andMAY revert due to other conditions that would also cause ``withdraw`` to revert
;previewRedeem
MUST return as close to and no more than the exact amount of assets that would be withdrawn in a ``redeem`` call in the same transaction
andMAY revert due to other conditions that would also cause ``redeem`` to revert
.Yet, although no
assets
can be deposited, noshares
can be minted, noassets
can be withdrawn, and noshare
can be redeemed through suchdeposit
,mint
,withdraw
, andredeem
functions, theAccountingManager
contract'spreviewDeposit
,previewMint
,previewWithdraw
, andpreviewRedeem
functions below can still return positive values, which are incorrect based on the EIP-4626 standard. Hence, thesepreviewDeposit
,previewMint
,previewWithdraw
, andpreviewRedeem
functions are not compliant with the EIP-4626 standard though https://code4rena.com/audits/2024-04-noya states that theAccountingManager
contract should be compliant with the EIP-4626 standard.https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/extensions/ERC4626.sol#L151-L168
Proof of Concept
Please add the following test in
testFoundry\TestAccounting.sol
. This test will pass to demonstrate the described scenario for thepreviewMint
function. The cases for thepreviewDeposit
,previewWithdraw
, andpreviewRedeem
functions are similar to it.Tools Used
Manual Review
Recommended Mitigation Steps
The
previewDeposit
,previewMint
,previewWithdraw
, andpreviewRedeem
functions in theAccountingManager
contract can be updated to revert because the correspondingdeposit
,mint
,withdraw
, andredeem
functions all revert. Then, theAccountingManager
contract can further add a function, which is similar to OpenZeppelin'spreviewDeposit
function, to replace thepreviewDeposit
function's usage in thecalculateDepositShares
andrecordProfitForFee
functions and add a function, which is similar to OpenZeppelin'spreviewRedeem
function, to replace thepreviewRedeem
function's usage in thecalculateWithdrawShares
function.Assessed type
Other
The text was updated successfully, but these errors were encountered: