code-423n4 / 2021-05-nftx-findings

1 stars 0 forks source link

User can avoid paying `directRedeemFee` by passively controlling the output of `getPseudoRand` #108

Closed code423n4 closed 3 years ago

code423n4 commented 3 years ago

Handle

shw

Vulnerability details

Impact

The getPseudoRand function uses a weak PRNG, based on blockhash(block.number - 1), which can be calculated on-chain by any smart contract beforehand. With the assist of Flashbots, users can revert transactions without paying gas fees to the miner. Thus, before interacting with the Vault, a user can calculate the result of randomness first to see if it is satisfying. If not, he reverts the transactions and retries multiple times as his desire. In short, the output randomness is predictable and potentially controllable (especially when the variable modulus is not large enough) without the user paying gas fees but only a tip to the miner.

In both redeemTo and swapTo functions, the directRedeemFee and redeemFee seem to be different. Assuming that directRedeemFee is greater than redeemFee, a user could exploit the potentially controllable output of randomness to redeem or swap specific chosen NFTs but avoid paying directRedeemFee at the same time.

Proof of Concept

Referenced code: NFTXVaultUpgradeable.sol#L413-L427 NFTXVaultUpgradeable.sol#L245-L247 NFTXVaultUpgradeable.sol#L280-L282

Tools Used

None

Recommended Mitigation Steps

Use Chainlink VRF to generate randomness.