ParaSpace contest - ayeslick's results

The First Ever Cross-Margin NFT Financialization Protocol.

General Information

Platform: Code4rena

Start Date: 28/11/2022

Pot Size: $192,500 USDC

Total HM: 33

Participants: 106

Period: 11 days

Judge: LSDan

Total Solo HM: 15

Id: 186

League: ETH

ParaSpace

Findings Distribution

Researcher Performance

Rank: 31/106

Findings: 2

Award: $835.72

QA:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: gzeon

Also found by: Dravee, ayeslick

Labels

bug
2 (Med Risk)
satisfactory
duplicate-215

Awards

731.7962 USDC - $731.80

External Links

Lines of code

https://github.com/code-423n4/2022-11-paraspace/blob/main/paraspace-core/contracts/misc/marketplaces/X2Y2Adapter.sol#L31

Vulnerability details

Impact

If a customer sets canFail to true for a X2Y2 order and the order fails, the ETH is not refunded to them..

Proof of Concept

customer sets canFail to true customer calls function An order fails X2Y2 sends ETH back to PoolMarketplace PoolMarketplace doesn’t refund the customer.

Prevent customers from setting canFail to true in the X2Y2 adapter.

#0 - c4-judge

2022-12-20T17:08:44Z

dmvt marked the issue as duplicate of #34

#1 - c4-judge

2023-01-23T20:46:07Z

dmvt marked the issue as satisfactory

Lines of code

https://github.com/code-423n4/2022-11-paraspace/blob/main/paraspace-core/contracts/misc/marketplaces/X2Y2Adapter.sol#L31

Vulnerability details

Impact

An operator can grief PoolMarketplace by draining its WETH into X2Y2

In its run function X2Y2 checks if input.shared.amountToEth is greater than 0. If it is, WETH is moved from msg.sender to X2Y2 with amountToEth is set to the amount of WETH unwrapped. amountToEth is the result of amountToEth minus the uint256 returned by the _run function. The X2Y2 adapter doesn’t check input.shared.amountToEth.

What is the currency set to? DAI, in this case

Why? When the _run function is called it returns an amount which is subtracted from and saved to amountToEth.

Why does this matter? When amountToEth is 0 the X2Y2 contract will not send any ETH back.

What does this mean? When an operator uses calls the X2Y2 contract via PoolMarketplace setting his currency to an accepted ERC20, DAI, and input.shared.amountToEth to a non zero amount, WETH is moved from PoolMarketplace to the X2Y2 contract in the specified amount because PoolMarketplace is the msg.sender. Because currency is set to DAI, in this case, it is moved from PoolMarketplace to X2Y2 and saved to the nativeAmount which is used to determine amountToEth.

Succinctly? This bug allows an operator to grief the PoolMarketplace contract. It does this by setting input.shared.amountToEth to the amount of WETH in the contract, setting currency to an accepted ERC20 that isn’t WETH and setting amount to equal PoolMarketplaces’ total WETH amount.

Proof of Concept

PoolMarketplace has 50 WETH Operator creates NFT Operator sets NFTs price to 50 DAI Operator calls buyWithCredit using X2Y2 adapter with currency set to DAI and with input.shared.amountToEth = 50 WETH When the run function within X2Y2 is called 50 WETH is pulled from PoolMarketplace into X2Y2 setting amountEth to 50. amountEth is set to 0 via the _takePayment function which transfers the 50 DAI to the X2Y2 setting nativeAmount to 50. When the _run function returns it returns 50, 50 - 50, setting amountEth to 0. 50 DAI is paid to the operator less fees PoolMarketplace isn’t refunded it’s ETH because amountEth == 0.

Require input.shared.amountToEth && input.shared.amountToWeth == 0.

#0 - c4-judge

2022-12-20T18:05:08Z

dmvt marked the issue as duplicate of #54

#1 - c4-judge

2023-01-23T15:43:57Z

dmvt marked the issue as satisfactory

#2 - c4-judge

2023-01-31T17:30:20Z

dmvt marked the issue as not a duplicate

#3 - c4-judge

2023-01-31T17:30:34Z

dmvt changed the severity to QA (Quality Assurance)

#4 - c4-judge

2023-01-31T17:30:49Z

dmvt marked the issue as grade-b

#5 - dmvt

2023-01-31T17:33:57Z

There's really no reason for anyone to ever do this.

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter