Nondeterministic clone can cause issues in case of reorg #573
Labels
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
grade-a
primary issue
Highest quality submission among a set of duplicates
Q-02
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/code-423n4/2024-04-panoptic/blob/833312ebd600665b577fbd9c03ffa0daf250ed24/contracts/PanopticFactory.sol#L240-L245
Vulnerability details
Impact
Collateral trackers are cloned non-deterministically. In case of a reorg this can cause users to deposit different amounts of funds into trackers than they intended to and leaving them with a lower liquidation point than planned.
Proof of Concept
The
PanopticFactory.deployNewPool
function creates new pools and contracts like this:While the pool address is deterministic, the collateral tracker addresses are not. A scenario where this can cause issues:
Block 1:
2 panoptic pools for 2 different uniswap pools are deployed0x123
0x1
0x2
0x456
0x3
0x4
Block 2:
a user operates a bot that automatically deposits funds and sells options if deemed potentially lucrativeNow imagine a reorg happens and the
new Block 1
will have swapped the deployment transactions:0x456
0x1
(previously0x3
)0x2
(previously0x4
)0x123
0x3
(previously0x1
)0x4
(previously0x2
)Since the transactions of the user bot have already been submitted they will still be processed with their original tx data. In a good case, they will just revert, but it can also happen that they pass and the user will have deposited collateral and sold options, except now the collateral deposits have been reversed and the user may end up with a lower liquidation point for a more volatile pool.
Tools Used
Manual review
Recommended Mitigation Steps
Also use
cloneDeterministic
for the CollateralTrackers (can use the samesalt
as used for the PanopticPool)Assessed type
Other
The text was updated successfully, but these errors were encountered: