Open code423n4 opened 1 year ago
hansfriese marked the issue as satisfactory
hansfriese marked the issue as primary issue
Marked as primary to credit pointing out an interesting scenario in the PoC. Mitigation is well written at #24.
wukong-particle marked the issue as sponsor confirmed
hansfriese marked the issue as selected for report
Lines of code
https://github.com/code-423n4/2023-05-particle/blob/1caf678bc20c24c96fc8f6b0046383ff0e9d2a6f/contracts/protocol/ParticleExchange.sol#L420
Vulnerability details
Impact
In the function
_execBuyNftFromMarket()
, if the user chooses to useWETH
, the function deposits ETH and approves theamount
of WETH to the marketplace. After executing the trade at the marketplace, the function checks that the balance decrease is correct in the end. However, this check only accounts for ETH changes, not WETH changes, which is incorrect. If the trade did not use the full amount of WETH approved to the marketplace, some leftover WETH will remain in the contract. This amount of WETH/ETH will be locked in the contract, even though it should belong to the borrower who was able to get a good offer to buy the NFT at a lower price.Proof of Concept
Consider the following scenario:
buyNftFromMarket()
to acquire an NFT with a price of 100 WETH. However, she sets the amount to 105 WETH, so the contract deposits and approves 105 WETH to the marketplace. After the trade, there is still 5 WETH approved to the marketplace.buyNftFromMarket()
to acquire an NFT with a price of 5 WETH. He specifies theuseToken = 0
. However, he sets theamount = 0
and actually uses the 5 WETH left in step 1 of Alice to acquire the NFT. The result is Bob is able to steal 5 WETH approved to the marketplace.Tools Used
Manual Review
Recommended Mitigation Steps
Consider accounting for the WETH when checking balance changes in
_execBuyNftFromMarket()
.Assessed type
Invalid Validation