Skip to content
Business logic Audit finding Advanced

BondVault BASE incentive can be gamed

The BondVault matched any deposited token amount with BASE liquidity at the pool's current swap price, so an attacker could manipulate the pool price before bonding and then reverse the manipulation to profit. This let the attacker effectively steal a share of the BASE the DAO supplied to the pool.

cmichel Follow

Originally disclosed on Code4rena

Submitted by cmichel

BondVault deposits match any deposited token amount with the BASE amount to provide liquidity, see Docs and DAO.handleTransferIn. The matched BASE amount is the swap amount of the token trade in the pool. An attacker can manipulate the pool and have the DAO commit BASE at bad prices which they then later buys back to receive a profit on BASE. This is essentially a sandwich attack abusing the fact that one can trigger the DAO to provide BASE liquidity at bad prices:

  1. Manipulate the pool spot price by dripping a lot of BASE into it repeatedly (sending lots of smaller trades is less costly due to the path-independence of the continuous liquidity model). This increases the token per BASE price.
  2. Repeatedly call DAO.bond(amount) to drip tokens into the DAO and get matched with BASE tokens to provide liquidity. (Again, sending lots of smaller trades is less costly.) As the pool contains low token but high BASE reserves, the spartaAllocation = _UTILS.calcSwapValueInBase(_token, _amount) swap value will be high. The contract sends even more BASE to the pool to provide this liquidity.
  3. Unmanipulate the pool by sending back the tokens from 1. As a lot more BASE tokens are in the reserve now due to the DAO sending it, the attacker will receive more BASE as in 1. as well, making a profit

The DAO’s Bond allocation can be stolen. The cost of the attack is the trade fees in 1. + 3. as well as the tokens used in 2. to match the BASE, but the profit is a share on the BASE supplied to the pool by the DAO in 2.

Track a TWAP spot price of the TOKEN <> BASE pair and check if the BASE incentive is within a range of the TWAP. This circumvents that the DAO commits BASE at bad prices.

verifyfirst (Spartan) acknowledged and disagreed with severity:

Implementing a TWAP needs more discussion and ideas to help with price manipulation. Attacking BOND is limited by its allocation, time and the fact that it’s locked over 6months.

ghoul-sol (judge) commented:

Per sponsor comment making this medium risk

The original report as published on Code4rena, by cmichel. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the vault used the pool's instantaneous swap price to size its BASE contribution, with no time-weighted or sanity check against manipulation.

Impact

The DAO's bond allocation could be stolen, though the sponsor argued the attack is limited by the allocation size, timing and a six-month lock, and the judge rated it medium risk.

What the attacker needed

Ability to trade the token/BASE pool; capital to manipulate the pool; bond allocation available

The fix

The report recommends tracking a time-weighted average price of the token/BASE pair and only allowing the BASE incentive when it falls within a range of that average.

How it was found

  1. Manipulate the pool spot price by repeatedly sending small BASE trades to raise the token-per-BASE price.
  2. Repeatedly call the bond function with small token amounts so the DAO matches them with BASE at the inflated swap value.
  3. Reverse the manipulation by sending the tokens back, receiving more BASE than was spent because the DAO added BASE to the reserve.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A liquidity pool is a pot of two tokens that sets prices based on how much of each it holds. The vault trusted that price when deciding how much of its own token to add, so someone who first skewed the pot could make the vault add too much and then profit by undoing the skew. This is a sandwich attack: pushing a price, letting a victim trade at the bad price, then reversing.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by cmichel

View all

196 more disclosed reports, best first.

More from Spartan Protocol Contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.