Skip to content
Access control Audit finding Intermediate

Adversary can steal approved tOLP s to Magnetar via _paricipateOnTOLP

The Magnetar contract's _participateOnTOLP function allowed a caller to specify any tOLP token ID without verifying ownership, so an attacker could use an approved tOLP from another user to participate and receive the resulting oTAP NFT. This let the attacker steal the innocent user's tOLP and mint the oTAP to themselves.

deadrxsezzz Follow

Originally disclosed on Code4rena

Submitted by deadrxsezzz

Any user could steal any approved tOLP to Magnetar. This is because within the Magnetar call, if the user has not minted a tOLP NFT, they can participate with any id they wish, by inputting it in participateData.

    function _participateOnTOLP(
        IOptionsParticipateData memory participateData,
        address user,
        address lockDataTarget,
        uint256 tOLPTokenId
    ) internal {
        if (!cluster.isWhitelisted(0, participateData.target)) {
            revert Magnetar_TargetNotWhitelisted(participateData.target);
        }

        // Check tOLPTokenId
        if (participateData.tOLPTokenId != 0) {
            if (participateData.tOLPTokenId != tOLPTokenId && tOLPTokenId != 0) {
                revert Magnetar_tOLPTokenMismatch();
            }

            tOLPTokenId = participateData.tOLPTokenId;  // @audit - does not verify sender owns that token
        }
        if (tOLPTokenId == 0) revert Magnetar_ActionParamsMismatch();

        IERC721(lockDataTarget).approve(participateData.target, tOLPTokenId);
        uint256 oTAPTokenId = ITapiocaOptionBroker(participateData.target).participate(tOLPTokenId);

        address oTapAddress = ITapiocaOptionBroker(participateData.target).oTAP();
        IERC721(oTapAddress).safeTransferFrom(address(this), user, oTAPTokenId, "0x");
    }

The only thing to consider is that the following line, must not revert:

IERC721(lockDataTarget).approve(participateData.target, tOLPTokenId);

Since the contract will not be an owner of tOLPTokenId, we’ll need to input a custom malicious lockDataTarget address, for which the approve will not revert. The lockDataTarget is not used at any other place within that function, so there’ll be no problem inputting a malicious address here.

After doing the described steps above, the attacker will lock the innocent user’s tOLP and get the oTAP NFT minted to themselves, effectively stealing the innocent user’s NFT.

Recommended Mitigation Steps

Verify that the sender owns that tOLP id.

Assessed type

ERC721

0xWeiss (Tapioca) confirmed


The original report as published on Code4rena, by deadrxsezzz. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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 function did not verify that the caller owned the tOLP token ID they supplied.

Impact

An attacker could steal any approved tOLP from another user and receive the oTAP NFT themselves.

What the attacker needed

Victim has approved tOLP to Magnetar; attacker can call Magnetar

The fix

The function should verify that the sender owns the tOLP token ID before using it.

How it was found

  1. Call Magnetar with a participateData containing the victim's tOLP token ID.
  2. Provide a malicious lockDataTarget address so the approve call does not revert.
  3. The contract approves the malicious target and calls participate with the victim's token ID.
  4. The oTAP NFT is minted and transferred to the attacker.

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.

A user can approve another contract to use their NFT. Here, a function let anyone choose which NFT to use without checking if they owned it. So an attacker could pick someone else's approved NFT, use it, and get the reward for themselves.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by deadrxsezzz

View all

11 more disclosed reports, best first.

More from Tapioca Invitational

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.