Skip to content
Business logic Audit finding Intermediate

Randomization of NFTs returned in redeem/swap operations can be brute-forced

The NFT redemption process used on-chain randomness (nonce and blockhash) to select which NFT a user receives, but a user could repeatedly call the redeem function from a contract and revert if the returned NFT was not the desired one, effectively brute-forcing the randomness. This allowed users to obtain specific NFTs rather than a random one, subverting the intended random distribution.

NFTX contest

Originally disclosed on Code4rena

If we assume that certain NFTs in a vault over time will have different market demand/price, then the users will try to redeem those specific NFTs. Even if direct redeems are disabled to prevent such a scenario to default to returning randomized NFTs, a user can brute-forced this on-chain randomization (using nonce + blockhash) by repeatedly trying to redeem/swap from a contract, checking the NFT IDs returned from the function and reverting the transaction if those are not the NFT IDs of specific interest.

The impact will be a subversion of the randomization goal to return random NFTs which cannot be specified by the user.

A similar exploit happened recently with Meebit NFTs.

Recommend considering only EOA (external only account) for redeem/swap operations to prevent brute-forcing via contracts. Alternatively, make the user commit to pseudo-random IDs before revealing them.

**- 0xKiwi acknowledged **

The original report as published on Code4rena. 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

The randomness used to select NFTs was derived from on-chain values (nonce and blockhash) that a user could influence or predict, and the redeem function allowed contracts to call it and revert based on the outcome.

Impact

The randomization goal is subverted, allowing users to obtain specific NFTs instead of random ones, which could disadvantage other users and undermine the intended fairness of the system.

What the attacker needed

Ability to deploy a smart contract; redeem/swap function callable by contracts

The fix

The report recommends restricting redeem/swap operations to externally owned accounts (EOAs) to prevent brute-forcing via contracts, or alternatively having users commit to pseudo-random IDs before revealing them.

How it was found

  1. A user deploys a smart contract that calls the redeem/swap function.
  2. The contract checks the NFT IDs returned from the function.
  3. If the returned NFT IDs are not the ones of interest, the contract reverts the transaction.
  4. The user repeats the process until the desired NFT IDs are returned.

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 you redeem an NFT from a vault, the system is supposed to give you a random one. But the randomness was predictable because it used information available on the blockchain. A user could write a smart contract that tries to redeem, checks which NFT it got, and cancels the transaction if it's not the one they want, repeating until they get the desired NFT.

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 from NFTX contest

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.