0x73696d616f - BancorExchangeProvider::executeSwap()
may set a supply of 0 which will brick the contract
#36
Labels
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Will Fix
The sponsor confirmed this issue will be fixed
0x73696d616f
Medium
BancorExchangeProvider::executeSwap()
may set a supply of 0 which will brick the contractSummary
BancorExchangeProvider::executeSwap() allows setting a supply or reserve of
0
which will brick the contract as all formulas inBancorFormula
for swapping tokens revert if thesupply
orreserve
is 0, which will lead to redeployment.Root Cause
In
BancorExchangeProvider:286
, the supply or reserve may be set to 0.In
BancorFormula:199,200,246,257,290,291,333,334
it reverts if supply or reserve are 0.The contracts following the
Broker::swapIn()
orBroker::swapOut()
calls flow allow swapping and making the supply or reserve 0.Internal pre-conditions
None.
External pre-conditions
None.
Attack Path
Impact
The protocol is bricked and has to be redeployed.
PoC
Explaining the flow for swapping in only, as swapping out is similar.
Broker::swapIn()
does not deal with a swap resulting in 0 supply or reserve.Broker::swapIn()
:It calls
GoodDollarExchangeProvider::swapIn()
, which also does not prevent this scenario:It then calls
BancorExchangeProvider.swapIn()
, which again allows swapping all supply or reserve:BancorExchangeProvider::_getScaledAmountOut()
does not deal with this and lastlyBancorFormula::purchaseTargetAmount()
andBancorFormula::saleTargetAmount()
allow swapping all supply or reserve.Mitigation
Deal with users swapping the whole supply or reserve, for example by always keeping a minimum amount.
The text was updated successfully, but these errors were encountered: