Skip to content
Business logic Audit finding Intermediate

Inappropriate handling of referralFee makes collecting Mirror fails without error when referrerProfileId is burned

When a Mirror publication with a referral fee is collected, the contract looks up the referrer's profile owner; if that profile has been burned, the lookup reverts and the collect fails. An attacker could not exploit this for gain, but users are unable to collect from Mirrors published by burned profiles.

WatchPug Follow

Originally disclosed on Code4rena

Submitted by WatchPug, also found by cccz

In the current implementation, even when the profile’s owner burnt the ProfileNFT, as the profile’s legacy, the publications can still be collected.

However, if the publication is a Mirror and there is a referralFee set by the original publication, the user won’t be able to collect from a Mirror that was published by a burned profile.

FeeCollectModule.sol#L163-L172

if (referralFee != 0) {
    // The reason we levy the referral fee on the adjusted amount is so that referral fees
    // don't bypass the treasury fee, in essence referrals pay their fair share to the treasury.
    uint256 referralAmount = (adjustedAmount * referralFee) / BPS_MAX;
    adjustedAmount = adjustedAmount - referralAmount;

    address referralRecipient = IERC721(HUB).ownerOf(referrerProfileId);

    IERC20(currency).safeTransferFrom(collector, referralRecipient, referralAmount);
}

When a mirror is collected, what happens behind the scenes is the original, mirrored publication is collected, and the mirror publisher’s profile ID is passed as a “referrer.”

In _processCollectWithReferral(), if there is a referralFee, contract will read referralRecipient from IERC721(HUB).ownerOf(referrerProfileId), if referrerProfileId is burned, the IERC721(HUB).ownerOf(referrerProfileId) will revert with ERC721: owner query for nonexistent token.

However, since we wish to allow the content to be collected, we should just treat referrals as non-existent in this situation.

Recommended Mitigation Steps

Change to:

try IERC721(HUB).ownerOf(referrerProfileId) returns (address referralRecipient) {
    uint256 referralAmount = (adjustedAmount * referralFee) / BPS_MAX;
    adjustedAmount = adjustedAmount - referralAmount;

    address referralRecipient = IERC721(HUB).ownerOf(referrerProfileId);

    IERC20(currency).safeTransferFrom(collector, referralRecipient, referralAmount);
} catch {
    emit LogNonExistingReferrer(referrerProfileId);
}

Zer0dot (Aave Lens) acknowledged and commented:

This is valid! However, this is only an issue when a profile is deleted (burned), in which case UIs have multiple choices:

1. Stop displaying all the burnt profile's publications
2. Redirect users, when collecting mirrors, to the original publication
3. Prevent all collects

I don’t think this adds any risk to the protocol and although it’s valid, we will not be taking any action.


The original report as published on Code4rena, by WatchPug. 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 contract calls ownerOf on a burned profile ID without handling the revert, so the entire collect transaction fails.

Impact

Users cannot collect from a Mirror published by a burned profile when a referral fee is set; the protocol team stated this adds no risk and chose not to fix it.

What the attacker needed

A Mirror publication with a referral fee; the Mirror publisher's profile is burned

The fix

The lookup should be wrapped in a try/catch so that a missing referrer is treated as non-existent and the collect still succeeds.

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 'Mirror' is a repost of someone else's content. When you collect (buy) a Mirror, the system pays a small referral fee to the person who made the Mirror. If that person's profile has been deleted (burned), the system tries to look up their address and crashes instead of just skipping the fee. This means you cannot collect that Mirror at all.

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.

More by WatchPug

View all

197 more disclosed reports, best first.

More from Aave Lens contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.