-
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
maxDeposit
, maxMint
, maxWithdraw
, and maxRedeem
functions do not return 0 when they should
#1517
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) |
This previously downgraded issue has been upgraded by gzeon-c4 |
gzeon-c4 marked the issue as partial-25 |
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/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/extensions/ERC4626.sol#L131-L148
https://github.com/code-423n4/2024-04-noya/blob/cc3854f634a72bd4a8b597021887088ca2d6d29f/contracts/accountingManager/AccountingManager.sol#L200-L219
https://github.com/code-423n4/2024-04-noya/blob/cc3854f634a72bd4a8b597021887088ca2d6d29f/contracts/accountingManager/AccountingManager.sol#L304-L316
https://github.com/code-423n4/2024-04-noya/blob/cc3854f634a72bd4a8b597021887088ca2d6d29f/contracts/accountingManager/AccountingManager.sol#L693-L707
Vulnerability details
Impact
The
AccountingManager
contracts'maxDeposit
andmaxMint
functions below always returntype(uint256).max
andmaxWithdraw
andmaxRedeem
functions below would return positive values whenbalanceOf(owner)
is positive. However, when thedeposit(address receiver, uint256 amount, address referrer)
andwithdraw(uint256 share, address receiver)
functions below are paused, calling these functions would revert in which noamount
can be deposited and noshare
can be withdrawn; in this case, the positive values returned by themaxDeposit
,maxMint
,maxWithdraw
, andmaxRedeem
functions are incorrect and misleading.https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/extensions/ERC4626.sol#L131-L148
https://github.com/code-423n4/2024-04-noya/blob/cc3854f634a72bd4a8b597021887088ca2d6d29f/contracts/accountingManager/AccountingManager.sol#L200-L219
https://github.com/code-423n4/2024-04-noya/blob/cc3854f634a72bd4a8b597021887088ca2d6d29f/contracts/accountingManager/AccountingManager.sol#L304-L316
Moreover, calling the
deposit(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 so noassets
can be deposited, noshares
can be minted, noassets
can be withdrawn, and noshare
can be redeemed through these functions; in this case, the positive values returned by themaxDeposit
,maxMint
,maxWithdraw
, andmaxRedeem
functions are also incorrect and misleading.As specified in https://eips.ethereum.org/EIPS/eip-4626:
maxDeposit
MUST factor in both global and user-specific limits, like if deposits are entirely disabled (even temporarily) it MUST return 0
;maxMint
MUST factor in both global and user-specific limits, like if mints are entirely disabled (even temporarily) it MUST return 0
;maxWithdraw
MUST factor in both global and user-specific limits, like if withdrawals are entirely disabled (even temporarily) it MUST return 0
;maxRedeem
MUST factor in both global and user-specific limits, like if redemption is entirely disabled (even temporarily) it MUST return 0
.Since the current
maxDeposit
,maxMint
,maxWithdraw
, andmaxRedeem
functions do not return 0 when they should, these functions are not compliant with the EIP-4626 standard even though theAccountingManager
contract should be compliant with the EIP-4626 standard according to https://code4rena.com/audits/2024-04-noya.https://github.com/code-423n4/2024-04-noya/blob/cc3854f634a72bd4a8b597021887088ca2d6d29f/contracts/accountingManager/AccountingManager.sol#L693-L707
Proof of Concept
Please add the following test in
testFoundry\TestAccounting.sol
. This test will pass to demonstrate the described scenario for themaxDeposit
function. The cases for themaxMint
,maxWithdraw
, andmaxRedeem
functions are similar to it.Tools Used
Manual Review
Recommended Mitigation Steps
The
AccountingManager
contract can be updated to add themaxDeposit
,maxMint
,maxWithdraw
, andmaxRedeem
functions to override the corresponding functions in OpenZeppelin'sERC4626
contract. To be compliant with the EIP-4626 standard, these functions can always return 0 since calling thedeposit(uint256 assets, address receiver)
,mint(uint256 shares, address receiver)
,withdraw(uint256 assets, address receiver, address owner)
, andredeem(uint256 shares, address receiver, address shareOwner)
functions always revert. Moreover, two more functions that are similar to themaxDeposit
andmaxRedeem
functions can be added in theAccountingManager
contract to accompany thedeposit(address receiver, uint256 amount, address referrer)
andwithdraw(uint256 share, address receiver)
functions, and these two additional functions should respectively return 0 when the correspondingdeposit
andwithdraw
functions are respectively paused.Assessed type
ERC4626
The text was updated successfully, but these errors were encountered: