code-423n4 / 2021-11-vader-findings

0 stars 0 forks source link

Attacker can claim more IL by manipulating pool price then `removeLiquidity` #182

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

Handle

gzeon

Vulnerability details

Impact

Vader reimburse user IL immediately when user withdraw from the pool (VaderRouterV2.sol:L227), an attacker can therefore manipulate the pool balance causing a high IL, remove liquidity and restore the pool balance such that he will receive a larger IL reimbursement.

Proof of Concept

Let's assume our attacker own 100% of FOO-VADER 1) Attacker add 100 FOO and 100 VADER to the Pool 2) wait some block, or 1 year for max IL protection 3) In 1 transaction, attacker

The profit is constrained by gas cost, pool fee, % of pool controlled by the attacker and % of IL protection.

Recommended Mitigation Steps

Use twap price to determine P1 in VaderMath.sol:L84 when calculating IL to reduce risk of manipulation

SamSteinGG commented 3 years ago

Duplicate of #2

alcueca commented 2 years ago

Doesn't seem like a duplicate to me, @SamSteinGG?

SamSteinGG commented 2 years ago

@alcueca The stated trade cannot occur as trades are inherently limited by the CLP design of the protocol to one third of the available pair liquidity. As such, the illustrated pair would actually result in almost zero units retrieved back.