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.
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
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-Token1Royalties:- Address0 = 10,000 (1%)
- Address1 = 10,000 (1%)
- Address2 = 100,000 (10%)
- Address3 = 880,000 (88%)
-
Alice owns the
NFT-Token1 -
Alice
setBuyPrice()and listedNFT-Token1for10 ETH; -
Bob
buy()with10 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.
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
- An NFT contract implements getRoyalties() with a precision higher than basis points (e.g., 1e6 for 100%).
- A seller lists the NFT for sale on the marketplace.
- A buyer purchases the NFT.
- 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.