Attacker can steal the amount collected so far in the GroupBuy for NFT purchase.
The purchase function in GroupBuy.sol did not validate the user-supplied market contract address, allowing an attacker to supply a malicious contract that receives the raised funds and returns an address holding the NFT so ownership checks pass. The attacker could steal the collected ETH or acquire the NFT without contributing.
Submitted by Trust, also found by IllIllI and Lambda
purchase() in GroupBuy.sol executes the purchase call for the group. After safety checks, the NFT is bought with \_market’s execute() function. Supposedly it deploys a vault which owns the NFT. The code makes sure the vault is the new owner of the NFT and exits.
// Executes purchase order transaction through market buyer contract and deploys new vault
address vault = IMarketBuyer(_market).execute{value: _price}(_purchaseOrder);
// Checks if NFT contract supports ERC165 and interface ID of ERC721 tokens
if (ERC165Checker.supportsInterface(_nftContract, _INTERFACE_ID_ERC721)) {
// Verifes vault is owner of ERC-721 token
if (IERC721(_nftContract).ownerOf(_tokenId) != vault) revert UnsuccessfulPurchase();
} else {
// Verifies vault is owner of CryptoPunk token
if (ICryptoPunk(_nftContract).punkIndexToAddress(_tokenId) != vault)
revert UnsuccessfulPurchase();
}
// Stores mapping value of poolId to newly deployed vault
poolToVault[_poolId] = vault;
// Sets pool state to successful
poolInfo[_poolId].success = true;
// Emits event for purchasing NFT at given price
emit Purchase(_poolId, vault, _nftContract, _tokenId, _price);
The issue is that \_market user-supplied variable is not validated at all. Attacker can pass their malicious contract, which uses the passed funds to buy the NFT and store it in attacker’s wallet. It will return the NFT-holding wallet so the checks will pass. As a result, attacker has the NFT while they could have contributed nothing to the GroupBuy. Attacker can also just steal the supplied ETH and return the current address which holds the NFT.
Impact
Attacker can steal the amount collected so far in the GroupBuy for NFT purchase.
Proof of Concept
- Group assembles and raises funds to buy NFT X
- Attacker calls
purchase()and supplies their malicious contract in\_market, as described. - Attacker receives raised funds totalling
minReservePrices[_poolId] * filledQuantities[_poolId], as checked in line 182.
Recommended Mitigation Steps
\_market should be whitelisted, or supplied in createPool stage and able to be scrutinized.
mehtaculous (Tessera) confirmed and commented:
Agree with High severity. Solution is to check that the
vaultdeployed from the MarketBuyer is actually registered through theVaultRegistry. This would confirm that the vault is not a user address
stevennevins (Tessera) mitigated:
https://github.com/fractional-company/modular-fractional/pull/201
Status: Mitigation not confirmed. Full details in report from gzeon, and also included in the Mitigation Review section below.
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 `_market` address was user-supplied and not validated or whitelisted, so an attacker could substitute a malicious contract.
What the attacker needed
A GroupBuy pool with raised funds; attacker can call purchase()
The fix
The `_market` address should be whitelisted or supplied at pool creation and scrutinised; the team also suggested checking that the returned vault is registered in the VaultRegistry.
How it was found
- Group assembles and raises funds to buy NFT X
- Attacker calls `purchase()` and supplies their malicious contract in `_market`
- Attacker receives raised funds totalling `minReservePrices[_poolId] * filledQuantities[_poolId]`
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 group-buying smart contract lets people pool money to buy an NFT. The contract trusted a user-provided address for the marketplace, so an attacker could point it to their own contract that simply took the money and pretended to deliver the NFT. This let the attacker steal the pooled funds.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.