Skip to content
Business logic Audit finding Intermediate

Royalties can be distribution unfairly among creatorRecipients for NFT contracts with non-standard getRoyalties() returns

The NFT marketplace contract assumes that the getRoyalties() function returns values in basis points (where 100% is 10,000), but some NFT contracts may use a different precision. If a contract returns values with higher precision, the royalty distribution logic incorrectly treats any share above 10,000 as invalid and sends all royalties to the first recipient, unfairly distributing funds.

WatchPug Follow

Originally disclosed on Code4rena

Submitted by WatchPug

Based on our research, getRoyalties() is not a standardized API for NFT contracts to indicate how the royalties should be distributed among the recipients.

However, in the current implementation, it always assumes that getRoyalties() return in terms of BPS.

NFTMarketCreators.sol#L85-L112

NFTMarketFees.sol#L86-L90

if (creatorShares[i] > BASIS_POINTS) {
    // If the numbers are >100% we ignore the fee recipients and pay just the first instead
    maxCreatorIndex = 0;
    break;
}

As a result, if a particular implementation is returning get Royalties() with higher precision (say 1e6 for 100% instead of 1e4/BPS), the distribution of royalties can be distorted.

Proof of Concept

Given:

  • NFT-Token1 Royalties:

    • Address0 = 10,000 (1%)
    • Address1 = 10,000 (1%)
    • Address2 = 100,000 (10%)
    • Address3 = 880,000 (88%)
  • Alice owns the NFT-Token1

  • Alice setBuyPrice() and listed NFT-Token1 for 10 ETH;

  • Bob buy() with 10 ETH:

  • foundationFee = 0.5 ETH

  • creatorFee = 1 ETH

  • ownerRev = 8.5 ETH

Since creatorShares[address2] > BASIS_POINTS (10,000), all the creatorFee will be sent to the first address: Address0, which is expected to receive only 1% of the royalties.

Recommended Mitigation Steps

Consider removing this and change to:

// Determine the total shares defined so it can be leveraged to distribute below
uint256 totalShares;
unchecked {
  // The array length cannot overflow 256 bits.
  for (uint256 i = 0; i <= maxCreatorIndex; ++i) {
    // The check above ensures totalShares wont overflow.
    totalShares += creatorShares[i];
  }
}
if (totalShares == 0) {
  maxCreatorIndex = 0;
}

NickCuso (Foundation) acknowledged and commented:

This is a fair concern to raise, and a reasonable solution recommendation. We will consider making a change like this in the future.

AFAIK this API was first introduced by Manifold, which named and implemented the return value to be in basis points. It’s true that since this is not a standard that others may use a different precision, however we have not yet encountered any example of that.


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

Likely the contract assumes getRoyalties() always returns basis points and does not handle other precisions, causing it to discard all but the first recipient when any share exceeds 10,000.

Impact

Royalties could be distributed unfairly, with all fees going to the first recipient instead of being split according to the intended shares.

What the attacker needed

NFT contract uses non-BPS precision for royalties; NFT is listed and sold on the marketplace

The fix

The code should be changed to sum the shares and only fall back to the first recipient if the total is zero, rather than rejecting any share above 10,000.

How it was found

  1. An NFT contract implements getRoyalties() with a precision higher than basis points (e.g., 1e6 for 100%).
  2. A seller lists the NFT for sale on the marketplace.
  3. A buyer purchases the NFT.
  4. The marketplace calculates royalties and, because one share exceeds 10,000, sends all royalties to the first recipient.

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.

When an NFT is sold, royalties are split among creators according to percentages. The marketplace expects these percentages to be expressed in basis points, where 100% equals 10,000. If an NFT contract uses a different scale, like 1,000,000 for 100%, the marketplace misreads the numbers and gives all the royalty money to the first creator instead of splitting it correctly.

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 Foundation Exhibition, Scheduling & Early Access Solo Audit by Lambda

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.