Platform: Code4rena
Start Date: 16/12/2022
Pot Size: $60,500 USDC
Total HM: 12
Participants: 58
Period: 5 days
Judge: Trust
Total Solo HM: 4
Id: 196
League: ETH
Rank: 13/58
Findings: 1
Award: $1,330.41
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Jeiwan
Also found by: Koolex, Ruhum, rotcivegaf
1330.4109 USDC - $1,330.41
The owner of the ERC721 token could approve an operator to manage his tokens
With the misunderstanding of operator
with from
in the onERC721Received
function the benefits of this function goes to the operator
instead of the from
(owner):
_addCollateralToVault(from, collateral);
the operator
can remove the collateral(NFT) instead of the original owner_increaseDebtAndSell(from, request.proceedsTo, ERC721(msg.sender), request.swapParams, request.oracleInfo);
increasing the debt and sell to the operator
instead of the original owner_increaseDebt(from, collateral.addr, request.proceedsTo, request.debt, request.oracleInfo);
increasing the debt of the operator
instead of the original ownerNote: read the
interface ERC721TokenReceiver
in EIP721
setApprovalForAll
or approve
)onERC721Received
call the internal functions _addCollateralToVault
and/or _increaseDebtAndSell
or _increaseDebt
with the from
as the operator parameterremoveCollateral
because Kane(the operator) it's the collateralOwner
, setted in collateralOwner[collateral.addr][collateral.id] = account;
Add this in the test contract OnERC721ReceivedTest:
function testOnERC721ReceivedWithOperator() public { vm.startPrank(borrower); safeTransferReceivedArgs.swapParams.sqrtPriceLimitX96 = _maxSqrtPriceLimit(true); address alice = address(2); nft.approve(alice, collateralId); vm.stopPrank(); vm.startPrank(alice); nft.safeTransferFrom(borrower, address(controller), collateralId, abi.encode(safeTransferReceivedArgs)); // This should be pass IPaprController.VaultInfo memory vaultInfo = controller.vaultInfo(borrower, collateral.addr); assertEq(vaultInfo.count, 1); assertEq(vaultInfo.debt, debt); }
Review
@@ -156,7 +156,7 @@ contract PaprController is /// @param _id the id of the NFT /// @param data encoded IPaprController.OnERC721ReceivedArgs /// @return selector indicating succesful receiving of the NFT - function onERC721Received(address from, address, uint256 _id, bytes calldata data) + function onERC721Received(address, address from, uint256 _id, bytes calldata data) external override returns (bytes4)
#0 - c4-judge
2022-12-25T13:32:00Z
trust1995 marked the issue as satisfactory
#1 - c4-judge
2022-12-25T13:32:04Z
trust1995 marked the issue as primary issue
#2 - c4-judge
2022-12-25T17:45:58Z
trust1995 marked the issue as duplicate of #183