mintSynth() and burnSynth() can be front run
The mintSynth() and burnSynth() functions issue or redeem synthetic assets based on pool reserves, so each call moves the price, yet they accept no slippage limit. An attacker could front-run a large mint or burn to trade against the resulting price change and take value from the user.
Submitted by WatchPug
- https://github.com/code-423n4/2021-11-vader/blob/429970427b4dc65e37808d7116b9de27e395ce0c/contracts/dex-v2/pool/VaderPoolV2.sol#L126-L155
- https://github.com/code-423n4/2021-11-vader/blob/429970427b4dc65e37808d7116b9de27e395ce0c/contracts/dex-v2/pool/VaderPoolV2.sol#L179-L197
Given that mintSynth() and burnSynth() will issue and redeem assets based on the price of the pool (reserves), and they will create price impact based on the volume being minted and burnt.
However, the current implementation provides no parameter for slippage control, making them vulnerable to front-run attacks. Especially for transactions with rather large volumes.
Recommendation
Consider adding a minAmountOut parameter.
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 mint and burn functions compute amounts from live pool reserves without letting the caller specify a minimum output, so the transaction can be sandwiched.
Impact
Large mint or burn transactions could be front-run and sandwiched, causing the user to receive a worse amount than expected.
What the attacker needed
Attacker can see pending transactions; victim mints or burns a large volume
The fix
The functions should be fixed by adding a minimum-output parameter so callers can bound slippage.
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 pool sets prices from how much of each token it holds. When someone mints or burns a large amount, that price shifts. Because the function lets the user set no minimum acceptable result, someone watching the pending transaction can trade just before it and profit from the shift, leaving the user with a worse deal.
What is Race condition?
Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.