NFT flashloans can bypass sale constraints
The public sale contract required callers to hold an NFT during the first four weeks, but an attacker could borrow an NFT via a flash loan, participate in the sale, and return the NFT in the same transaction. This allowed anyone to bypass the NFT-holder restriction and access the sale.
Submitted by pauliax
Impact
Public sale has a constraint that for the first 4 weeks only NFT holders can access the sale:
if (currentEra < firstPublicEra) {
require(nft.balanceOf(msg.sender) > 0, "You need NFT to participate in the sale.");
}
However, this check can be easily bypassed with the help of flash loans. You can borrow the NFT, participate in the sale and then return this NFT in one transaction. It takes only 1 NFT that could be flashloaned again and again to give access to the sale for everyone (burnEtherForMember).
Recommended Mitigation Steps
I am not sure what could be the most elegant solution to this problem. You may consider transferring and locking this NFT for at least 1 block but then the user will need to do an extra tx to retrieve it back. You may consider taking a snapshot of user balances so the same NFT can be used by one address only but then this NFT will lose its extra benefit of selling it during the pre-sale when it acts as a pre-sale token. You may consider checking that the caller is EOA but again there are ways to bypass that too.
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 contract checked NFT ownership at the moment of the call, which can be manipulated within a single transaction using a flash loan.
Impact
Anyone could bypass the NFT-holder restriction and participate in the public sale, potentially gaining unfair access to tokens.
What the attacker needed
Access to a flash loan provider; an NFT available to borrow
The fix
The report suggests possible mitigations such as locking the NFT for at least one block, taking a snapshot of balances, or checking that the caller is an EOA, but notes that each has drawbacks and no definitive fix is provided.
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.
A flash loan is a loan that must be borrowed and repaid within the same transaction. The sale contract checked if the caller owned an NFT, but an attacker could temporarily borrow one, make the purchase, and return it instantly, all in one step. This let people who did not actually own an NFT join the sale.
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.