NTokenMoonBirds Reserve Pool Cannot Receive Airdrops
The NTokenMoonBirds Reserve Pool contract only accepts Moonbird NFTs because its onERC721Received function requires the sender to be the underlying Moonbird contract. As a result, any airdropped NFT other than a Moonbird is rejected, so users who collateralised nested Moonbirds cannot receive airdrops.
xiaoming90 Follow with cccz, imare and 2 others
Originally disclosed on Code4rena
Submitted by xiaoming90, also found by cccz, imare, unforgiven, and csanuragjain
The NTokenMoonBirds Reserve Pool only allows Moonbird NFT to be sent to the pool contract as shown in Line 70 below.
File: NTokenMoonBirds.sol
63: function onERC721Received(
64: address operator,
65: address from,
66: uint256 id,
67: bytes memory
68: ) external virtual override returns (bytes4) {
69: // only accept MoonBird tokens
70: require(msg.sender == _underlyingAsset, Errors.OPERATION_NOT_SUPPORTED);
71:
72: // if the operator is the pool, this means that the pool is transferring the token to this contract
73: // which can happen during a normal supplyERC721 pool tx
74: if (operator == address(POOL)) {
75: return this.onERC721Received.selector;
76: }
77:
78: // supply the received token to the pool and set it as collateral
79: DataTypes.ERC721SupplyParams[]
80: memory tokenData = new DataTypes.ERC721SupplyParams[](1);
81:
82: tokenData[0] = DataTypes.ERC721SupplyParams({
83: tokenId: id,
84: useAsCollateral: true
85: });
86:
87: POOL.supplyERC721FromNToken(_underlyingAsset, tokenData, from);
88:
89: return this.onERC721Received.selector;
90: }
Note that the NTokenMoonBirds Reserve Pool is the holder/owner of all Moonbird NFTs within ParaSpace. If there is any airdrop for Moonbird NFT, the airdrop will be sent to the NTokenMoonBirds Reserve Pool.
However, due to the validation in Line 70, the NTokenMoonBirds Reserve Pool will not be able to receive any airdrop (e.g. Moonbirds Oddities NFT) other than the Moonbird NFT. In summary, if any NFT other than Moonbird NFT is sent to the pool, it will revert.
For instance, Moonbirds Oddities NFT has been airdropped to Moonbird NFT nested stakers in the past. With the nesting staking feature, more airdrops are expected in the future. In this case, any users who collateralized their nested Moonbird NFT within ParaSpace will lose their opportunities to claim the airdrop.
Impact
Loss of assets for the user. Users will not be able to receive any airdropped assets for their nested Moonbird NFT.
Recommended Mitigation Steps
Update the contract to allow airdrops to be received by the NTokenMoonBirds Reserve Pool.
function onERC721Received(
address operator,
address from,
uint256 id,
bytes memory
) external virtual override returns (bytes4) {
- // only accept MoonBird tokens
- require(msg.sender == _underlyingAsset, Errors.OPERATION_NOT_SUPPORTED);
// if the operator is the pool, this means that the pool is transferring the token to this contract
// which can happen during a normal supplyERC721 pool tx
if (operator == address(POOL)) {
return this.onERC721Received.selector;
}
+ if msg.sender == _underlyingAsset(
// supply the received token to the pool and set it as collateral
DataTypes.ERC721SupplyParams[]
memory tokenData = new DataTypes.ERC721SupplyParams[](1);
tokenData[0] = DataTypes.ERC721SupplyParams({
tokenId: id,
useAsCollateral: true
});
+ )
POOL.supplyERC721FromNToken(_underlyingAsset, tokenData, from);
return this.onERC721Received.selector;
}
LSDan (judge) decreased severity to Medium
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 onERC721Received callback contains a hard require that the caller must be the underlying Moonbird contract, so any other NFT contract sending a token causes a revert.
Impact
Users could lose airdropped assets tied to their nested Moonbird NFTs because the pool rejects every non-Moonbird token.
What the attacker needed
User collateralises a nested Moonbird; an airdrop is sent to the pool
The fix
The contract should be changed so the reserve pool can accept airdropped NFTs, for example by only running the supply logic when the sender is the underlying asset and otherwise accepting the token.
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 deposit an NFT into a lending pool, the pool contract holds it for you. Some NFT projects send free bonus tokens (airdrops) to whoever holds the original NFT. Here the pool contract refuses to accept any token that is not the original Moonbird, so those free bonuses bounce back and are lost to the user.
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.