Closed code423n4 closed 1 year ago
outdoteth marked the issue as sponsor acknowledged
Valid, but adds complexity which increases the surface area of attack for marginal benefit (the existing solution still mitigates the original issue).
@outdoteth couldn't you just flashloan the token, do the operations and then return the token?
I guess they can just withdraw and re-deposit, since they own the tokens since they own the pool
Am I missing something?
Ah yes I think you are right @GalloDaSballo
GalloDaSballo changed the severity to QA (Quality Assurance)
The Owner is free to operate with the tokens via macros, the change does add overhead but doesn't fundamentally impede any functionality, valid QA imo
GalloDaSballo marked the issue as grade-c
Would rate as Low Severity, closing for awarding
Lines of code
https://github.com/outdoteth/caviar-private-pools/blob/main/src/PrivatePool.sol#L472
Vulnerability details
Impact
The mitigation for H-02: PrivatePool owner can steal all ERC20 and NFT from user via arbitrary execution and M-15: Pool tokens can be stolen via PrivatePool.flashLoan function from previous owner adds the following
InvalidTarget
error in thePrivatePool
contract and updates thePrivatePool.execute
function to executeif (target == address(baseToken) || target == address(nft)) revert InvalidTarget()
.https://github.com/outdoteth/caviar-private-pools/pull/2/files#diff-6beea546a01e795e1365ca8a74b2bd952631f6cd228a5a869bfed82bf1f46a0fR80
https://github.com/outdoteth/caviar-private-pools/pull/2/files#diff-6beea546a01e795e1365ca8a74b2bd952631f6cd228a5a869bfed82bf1f46a0fR460-R479
Because calling the
PrivatePool.execute
function whentarget
isbaseToken
ornft
now reverts, the private pool owner cannot use this function to transfer tokens ofbaseToken
ornft
for which users have approved thePrivatePool
contract as an operator. Thus, H-02: PrivatePool owner can steal all ERC20 and NFT from user via arbitrary execution is mitigated. This change also mitigates M-15: Pool tokens can be stolen via PrivatePool.flashLoan function from previous owner since the private pool owner can no longer call thePrivatePool.execute
function to approve other contract or EOA as the operator for the private pool'sbaseToken
andnft
tokens before becoming the previous owner of the same private pool.However, this mitigation prevents the private pool owner from performing some legitimate operations for
baseToken
andnft
tokens owned by the private pool. For example, if some rewards were accumulated for thebaseToken
tokens owned by the private pool, the private pool owner cannot call thePrivatePool.execute
function to claim these rewards from thebaseToken
contract; in this case, the private pool owner loses these rewards that she or he is entitled to. Although thePrivatePool.execute
function is meant for supporting the private pool owner's legitimate interactions withtarget
, such functionality becomes unavailable forbaseToken
andnft
after the mitigation.Proof of Concept
The following steps can occur for the described scenario.
baseToken
tokens owned by her private pool in the correspondingbaseToken
contract.PrivatePool.execute
function to interact with thebaseToken
contract reverts.Tools Used
VSCode
Recommended Mitigation Steps
Instead of executing
if (target == address(baseToken) || target == address(nft)) revert InvalidTarget()
, thePrivatePool.execute
function can be updated as follows.PrivatePool.execute
function should revert if the private pool does not own the token ID, which is included indata
, of thetarget
contract.PrivatePool.execute
function for the corresponding private pool; unsafe function selectors like these fortransfer
,transferFrom
,safeTransferFrom
,approve
, andsetApprovalForAll
should not be added to this list. This list can be empty at first and be updated on demand and by request of the private pool owner. Then, thePrivatePool.execute
function should revert if the function selector, which is also included indata
, is not found in this list.If these changes require too much work, keeping the current mitigation also works because the benefit still outweighs the cost. Yet, users need to be aware of such design choice so they understand the limitation of being private pool owners.
Assessed type
Other