TapiocaOptionBroker.participate() with the approve authorization, it still cannot be executed
The participate() function checks that the caller is approved for the tOLP NFT, but then passes the caller as the owner when transferring the token, so the transfer fails. An approved user therefore cannot participate, breaking a legitimate workflow.
bin2chen Follow with carrotsmuggler and cccz
Originally disclosed on Code4rena
Submitted by bin2chen, also found by carrotsmuggler and cccz
If the user isApproved(), the user can call TapiocaOptionBroker.participate(). The code is as follows:
function participate(uint256 _tOLPTokenID) external whenNotPaused nonReentrant returns (uint256 oTAPTokenID) {
...
TWAMLPool memory pool = twAML[lock.sglAssetID];
if (pool.cumulative == 0) {
pool.cumulative = EPOCH_DURATION;
}
@> if (!tOLP.isApprovedOrOwner(msg.sender, _tOLPTokenID)) {
revert NotAuthorized();
}
{
@> bool isErr = pearlmit.transferFromERC721(msg.sender, address(this), address(tOLP), _tOLPTokenID);
if (isErr) revert TransferFailed();
}
However, in the current implementation, even though msg.sender has obtained authorization (isApprovedOrOwner(msg.sender) == true), it is still unable to execute due to the incorrect usage of: pearlmit.transferFromERC721(msg.sender, address(this), address(tOLP), _tOLPTokenID); Passing msg.sender as the owner will result in failure to execute.
pearlmit.transferFromERC721(msg.sener,to) -> IERC721(token).transferFrom(owner, to) -> _transfer(owner,to) -> require(ERC721.ownerOf(tokenId) == owner.
It will check the first parameter is the owner of NFT. It should use: pearlmit.transferFromERC721(tOLP.ownerOf(_tOLPTokenID), address(this), address(tOLP), _tOLPTokenID).
Impact
Although msg.sender has been granted authorization, it is still unable to execute participate().
Recommended Mitigation
function participate(uint256 _tOLPTokenID) external whenNotPaused nonReentrant returns (uint256 oTAPTokenID) {
...
if (!tOLP.isApprovedOrOwner(msg.sender, _tOLPTokenID)) {
revert NotAuthorized();
}
// Transfer tOLP position to this contract
// tOLP.transferFrom(msg.sender, address(this), _tOLPTokenID);
{
- bool isErr = pearlmit.transferFromERC721(msg.sender, address(this), address(tOLP), _tOLPTokenID);
+ bool isErr = pearlmit.transferFromERC721(tOLP.ownerOf(_tOLPTokenID), address(this), address(tOLP), _tOLPTokenID);
if (isErr) revert TransferFailed();
}
Assessed type
Context
cryptotechmaker (Tapioca) commented:
PR here.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The code passes msg.sender as the owner argument to the ERC721 transfer, but the token contract requires that argument to be the actual owner of the token.
Impact
An approved user cannot call participate(), so the function is unusable for anyone who is not the token owner.
What the attacker needed
Caller is approved but not the owner; caller holds a valid tOLP token ID
The fix
The transfer should pass the token's actual owner (tOLP.ownerOf of the token ID) as the owner argument; a pull request was opened.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
An NFT owner can let someone else act on their token by approving them. Here the contract correctly checks that the caller is approved, but then tells the token contract that the caller is the owner, which is false, so the transfer is rejected. The fix is to pass the real owner's address instead of the caller's.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.