ParaSpace contest - mahdikarimi'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: 45/106

Findings: 1

Award: $266.74

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: ladboy233

Also found by: Kong, Lambda, R2, __141345__, mahdikarimi

Labels

bug
2 (Med Risk)
downgraded by judge
satisfactory
duplicate-242

Awards

266.7397 USDC - $266.74

External Links

Lines of code

https://github.com/code-423n4/2022-11-paraspace/blob/c6820a279c64a299a783955749fdc977de8f0449/paraspace-core/contracts/misc/UniswapV3OracleWrapper.sol#L156-L181 https://github.com/code-423n4/2022-11-paraspace/blob/c6820a279c64a299a783955749fdc977de8f0449/paraspace-core/contracts/misc/UniswapV3OracleWrapper.sol#L96-L107 https://github.com/code-423n4/2022-11-paraspace/blob/c6820a279c64a299a783955749fdc977de8f0449/paraspace-core/contracts/misc/UniswapV3OracleWrapper.sol#L156-L181

Vulnerability details

Impact

getTokenPrice function in UniswapV3OracleWrapper gets affected by flash loan attack .

Proof of Concept

Scenario : Attacker takes a flash loan and mint a new uniswap position ( or increase liquidity ) before getTokenPrice being called because this function uses liquidity amount ( increased due flash loan ) as a price factor makes it calculate a large number as price then after price calculated Attacker will remove the flash loaned amount from position and repay the flash loan and happening all of this in one transaction cause tokenPrice successfully get affect by flash loan .

1 .Take Flash Loan 2. increase Liquidity 3. getTokenPrice ( or any logic that use this function like borrow ) 4. decrease Liquidity 5. Repay FlashLoan

Tools Used

Manual Review

For solving this issue and protect against flash loan attacks you can transfer liquidity amount to a new position and assign that position to that user after transfer liquidity to a new position Attacker will not be able to remove flash loaned amount from position and repay flash loan so it will revert .

This solution requires keeps track of every position created this way for users , like a mapping of addresses to tokenIds .

#0 - c4-judge

2022-12-20T17:52:18Z

dmvt marked the issue as duplicate of #50

#1 - c4-judge

2023-01-09T16:43:01Z

dmvt changed the severity to 2 (Med Risk)

#2 - c4-judge

2023-01-23T16:15:46Z

dmvt marked the issue as satisfactory

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