Open sherlock-admin3 opened 7 months ago
The protocol team fixed this issue in the following PRs/commits: https://github.com/woonetwork/WooPoolV2/pull/110
request poc
PoC request not allowed.
We decided to downgrade it to med cause the cost of such attack is extremely high.
The Lead Senior Watson signed off on the fix.
KingNFT
high
Price manipulation by swapping any
baseToken
with itselfSummary
WooPPV2.swap()
doesn't forbid the case thatfromToken == toToken == baseToken
, attackers can make anybaseToken
's price unboundedly drifting away by swapping with self.Vulnerability Detail
The issue arises due to incorrect logic in
WooPPV2._swapBaseToBase()
:fromToken == toToken == baseToken
can pass the checks on L521\~L522.baseToken
's state & price is cached in memory on L527\~L528, and updated first time on L541, but the price calculation on L555 still uses the cached state, and thenewBase2Price
is set towooracle
on L556 as the final price after the swap.As a result, swapping
baseToken
with itself will cause a net price drift rather than keeping price unchanged.The following coded PoC intuitively shows the problem with a specific case:
And the logs:
Impact
Acccording
WooFI
doc (https://learn.woo.org/v/woofi-dev-docs/resources/on-chain-price-feeds), theWooracle
is intended to work as a price feed infrastructure for bothWooFI
's other components and third parties. This bug would cause all related consumer APPs suffering potential price manipulation attack.Code Snippet
https://github.com/sherlock-audit/2024-03-woofi-swap/blob/main/WooPoolV2/contracts/WooPPV2.sol#L513
Tool used
Manual Review
Recommendation