PA1D#bidSharesForToken returns incorrect bidShares.creator.value
The bidSharesForToken function returns creator bid share values in raw basis points instead of the 18-decimal percentage format expected by the Zora market. This causes incorrect royalty calculations when the market validates or uses the bid shares.
Submitted by 0x52
bidShares returned are incorrect leading to incorrect royalties.
Proof of Concept
function isValidBidShares(BidShares memory bidShares)
public
pure
override
returns (bool)
{
return
bidShares.creator.value.add(bidShares.owner.value).add(
bidShares.prevOwner.value
) == uint256(100).mul(Decimal.BASE);
}
Above you can see the Zora market lines that validate bidShares, which shows that Zora market bidShare.values should be percentages written out to 18 decimals. However PA1D#bidSharesForToken sets the bidShares.creator.value to the raw basis points set by the owner, which is many order of magnitudes different than expected.
Recommended Mitigation Steps
To return the proper value, basis points returned need to be adjusted. Convert from basis points to percentage by dividing by 10 ** 2 (100) then scale to 18 decimals. The final result it to multiple the basis point by 10 ** (18 - 2) or 10 ** 16:
function bidSharesForToken(uint256 tokenId) public view returns (ZoraBidShares memory bidShares) {
// this information is outside of the scope of our
bidShares.prevOwner.value = 0;
bidShares.owner.value = 0;
if (_getReceiver(tokenId) == address(0)) {
- bidShares.creator.value = _getDefaultBp();
+ bidShares.creator.value = _getDefaultBp() * (10 ** 16);
} else {
- bidShares.creator.value = _getBp(tokenId);
+ bidShares.creator.value = _getBp(tokenId) * (10 ** 16);
}
return bidShares;
}
alexanderattar (Holograph) commented:
Good catch! We’ll implement the suggested solution.
alexanderattar (Holograph) linked a PR:
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
Impact
Royalty calculations could be incorrect, potentially causing creators to receive the wrong amount.
What the attacker needed
None
The fix
The function should multiply the basis point value by 10^16 to convert it to an 18-decimal percentage; the project said it would implement this.
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.
Smart contracts often represent percentages as large integers with many decimal places. Here, one function returned a small whole number (basis points) where the market expected a number scaled up by 10^18, so the royalty amount was far too small. This could mean creators receive the wrong payment.
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.