Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
code423n4 opened this issue May 11, 2021 · 1 comment
Labels
2 (Med Risk) Acknowledged bug Something isn't working

Comments

@code423n4
Copy link
Contributor

Handle

0xRajeev

Vulnerability details

Impact

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 https://twitter.com/sillytuna/status/1391013965170454540

Proof of Concept

https://github.com/code-423n4/2021-05-nftx/blob/f6d793c136d110774de259d9f3b25d003c4f8098/nftx-protocol-v2/contracts/solidity/NFTXVaultUpgradeable.sol#L376

https://github.com/code-423n4/2021-05-nftx/blob/f6d793c136d110774de259d9f3b25d003c4f8098/nftx-protocol-v2/contracts/solidity/NFTXVaultUpgradeable.sol#L413-L427

Tools Used

Manual Analysis

Recommended Mitigation Steps

Consider onlyEOA for redeem/swap operations to prevent brute-forcing via contracts. Alternatively, make the user commit to pseudo-random IDs before revealing them.

@codyohl
Copy link

codyohl commented Aug 25, 2021

fyi, @cemozerr @0xKiwi the recommendation of onlyEOA doesn't really work as a mitigation because it can still be done (and would be more likely to be done because it's gasless) via a flashbots bundle with an address and then a contract. Correct me if i'm wrong?

see flashbots/pm#24 for why flashbots could offer this type of account abstraction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 (Med Risk) Acknowledged bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants