Skip to content
DoS Audit finding Intermediate

_getCreatorPaymentInfo() is Not Equipped to Handle Reverts on an Unbounded _recipients Array

The _getCreatorPaymentInfo() function uses try/catch to handle reverts from external calls, but reverts from internal calls (such as iterating over an unbounded _recipients array) are not caught. This could cause valid NFT contracts to revert during fund distribution, potentially locking NFTs in the contract.

leastwood Follow

Originally disclosed on Code4rena

Submitted by leastwood

NFTMarketCreators.sol#L49-L251

The _getCreatorPaymentInfo() function is utilised by _distributeFunds() whenever an NFT sale is made. The function uses try and catch statements to handle bad API endpoints. As such, a revert in this function would lead to NFTs that are locked in the contract. Some API endpoints receive an array of recipient addresses which are iterated over. If for whatever reason the function reverts inside of a try statement, the revert is actually not handled and it will not fall through to the empty catch statement.

Proof of Concept

The end result is that valid and honest NFT contracts may revert if the call runs out of gas due to an unbounded _recipients array. try statements are only able to handle external calls.

Recommended Mitigation Steps

Consider bounding the number of iterations to MAX_ROYALTY_RECIPIENTS_INDEX as this is already enforced by _distributeFunds(). It may be useful to identify other areas where the try statement will not handle reverts on internal calls.

NickCuso (Foundation) confirmed and commented:

Yes - this code is trying to be very defensive so that NFTs cannot get stuck in escrow. This is a great suggestion on how we could continue to improve.

Instead of capping the loop lengths in _getCreatorPaymentInfo we have opted to remove them entirely. There was another simplification that happened recently to this function that made removal a viable option. Now the only other loop for this data is in _distributeFunds and we already cap the max length there.


The original report as published on Code4rena, by leastwood. 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 try/catch block only handles external calls, so reverts from internal loops (e.g., due to gas exhaustion from an unbounded array) are not caught, leading to unexpected reverts.

Impact

Valid and honest NFT contracts may revert if the call runs out of gas due to an unbounded _recipients array, potentially locking NFTs in the contract.

What the attacker needed

NFT sale with many royalty recipients

The fix

The function was fixed by removing the loops entirely, as the only remaining loop in _distributeFunds is already capped.

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 use try/catch to handle errors from external calls, but this only works for calls to other contracts. If an error happens inside the same contract, like running out of gas while looping over a list, the try/catch won't catch it. This means a sale could fail and the NFT might get stuck.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by leastwood

View all

70 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.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.