RdpxV2Core._curveSwap minOut calculated wrongly when swapping dpxETH for ETH #1827
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-1558
partial-50
Incomplete articulation of vulnerability; eligible for partial credit only (50%)
Lines of code
https://github.com/code-423n4/2023-08-dopex/blob/eb4d4a201b3a75dd4bddc74a34e9c42c71d0d12f/contracts/core/RdpxV2Core.sol#L548-L549
Vulnerability details
This minOut calculation underestimate assets price:
https://github.com/code-423n4/2023-08-dopex/blob/eb4d4a201b3a75dd4bddc74a34e9c42c71d0d12f/contracts/core/RdpxV2Core.sol#L548-L549
Impact
Swap sandwitch attack and big slippage if minAmount = 0 (not set) when calling RdpxV2Core.upperDepeg
Proof of Concept
This executes when
_ethToDpxEth
= false => swapping dpxETH to ETH => upper depeg (1 eth < 1 dpxETH) => getEthPrice() < 1e8 (return eth price in dpxETH)Consider extreme case:
Tools Used
Manual Review
Recommended Mitigation Steps
Flip price and use insted
This gives minOut = 1.99e18, which is correct
Assessed type
Math
The text was updated successfully, but these errors were encountered: