Owner has to perpetually pay fees to withdraw fees, resulting in dust amount left in the contract #221
Labels
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-98
grade-a
insufficient quality report
This report is not of sufficient quality
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
Lines of code
https://github.com/code-423n4/2023-11-shellprotocol/blob/485de7383cdf88284ee6bcf2926fb7c19e9fb257/src/ocean/Ocean.sol#L1166-L1171
Vulnerability details
Proof of Concept
The owner gets fees every time
_grantFeeToOcean()
is invoked, (from unwrapping ether, ERC1155, ERC20 and wrapping ERC20)This fee is usually in the shToken format (except for the ERC1155 fees, which follows the ERC1155 token decimals), so when the owner wants to withdraw his fees in the ERC20 format, he will have to call unwrapERC20 as well.
When the owner calls the ERC20Unwrap interaction, he will have to pay fees as well. This means that whenever he wants to withdraw a sum of tokens, he will have to pay fees. Then, when he wants to withdraw the fees he paid, he will have to pay fees again. This will lead to a small sum of fees left inside the contract that cannot be withdrawn.
Eg. Owner has about 100e18 of shUSDC accumulated from fees that he wants to withdraw.
_erc20Unwrap()
to unwrap 100e18 shUSDC._erc20Unwrap()
to unwrap 5e16 shUSDCThis goes on perpetually; the owner cannot withdraw all his fees entirely.
Impact
Owner will have some fees stuck in the contract.
Tools Used
VSCode
Recommended Mitigation Steps
When calling
_grantFeeToOcean()
, if the msg.sender is the owner, then skip the function so that the owner don't have to pay his own fees.Assessed type
Invalid Validation
The text was updated successfully, but these errors were encountered: