NFT creator sales revenue recipients can steal gas #165
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/code-423n4/2022-08-foundation/blob/792e00df429b0df9ee5d909a0a5a6e72bd07cf79/contracts/mixins/shared/MarketFees.sol#L130
Vulnerability details
Impact
Selling a NFT with
NFTDropMarketFixedPriceSale.mintFromFixedPriceSale
distributes the revenue from the sale to various recipients with theMarketFees._distributeFunds
function.Recipients:
It is possible to have multiple NFT creators. Sale revenue will be distributed to each NFT creator address. Revenue distribution is done by calling
SendValueWithFallbackWithdraw._sendValueWithFallbackWithdraw
and providing an appropriate gas limit to prevent consuming too much gas. For the revenue distribution to the seller, protocol and the buy referrer, a gas limit ofSEND_VALUE_GAS_LIMIT_SINGLE_RECIPIENT = 20_000
is used. However, for the creators, a limit ofSEND_VALUE_GAS_LIMIT_MULTIPLE_RECIPIENTS = 210_000
is used. This higher amount of gas is used ifPercentSplitETH
is used as a recipient.A maximum of
MAX_ROYALTY_RECIPIENTS = 5
NFT creator recipients are allowed.For example, a once honest NFT collection and its 5 royalty creator recipients could turn "malicious" and could "steal" gas from NFT buyers on each NFT sale and therefore grief NFT sales. On each NFT sell, the 5 creator recipients (smart contracts) could consume the full amount of
SEND_VALUE_GAS_LIMIT_MULTIPLE_RECIPIENTS = 210_000
forwarded gas. Totalling5 * 210_000 = 1_050_000
gas. With a gas price of e.g.20 gwei
, this equals to additional gas costs of21_000_000 gwei = 0.028156 eth
, with aETH
price of2000
, this would total to ~56.31 $
additional costs.Proof of Concept
mixins/shared/MarketFees.sol#L130
Tools Used
Manual review
Recommended mitigation steps
Consider only providing a higher amount of gas (
SEND_VALUE_GAS_LIMIT_MULTIPLE_RECIPIENTS
) for the first creator recipient. For all following creator recipients, only forward the reduced amount of gasSEND_VALUE_GAS_LIMIT_SINGLE_RECIPIENT
.The text was updated successfully, but these errors were encountered: