You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Missing Slippage Protection in WeightedIndex.debond Enables Flash Loan-Powered Sandwich Attacks
Summary
The missing minimum output validation in WeightedIndex.debond will cause partial loss of funds for users withdrawing from the index as attackers can manipulate withdrawal ratios through flash loan-powered sandwich attacks. By front-running a user's WeightedIndex.debond transaction with a large WeightedIndex.bond operation funded by flash loans, attackers artificially inflate the index's total supply, reducing the victim's share percentage and withdrawn token amounts. This allows attackers to profit from the manipulated asset ratios while victims receive significantly less value than market rates.
Root Cause
The WeightedIndex.debond function in WeightedIndex.sol#L185-L191 lacks critical slippage protection mechanisms, enabling sandwich attacks through:
The _percSharesX96 ratio (L185) uses real-time _totalSupply that attackers can inflate via front-run WeightedIndex.bond calls
Withdrawal amounts are calculated based on current _totalAssets balances that can be altered through flash loan attacks
Absence of Minimum Output Checks:
No parameters allow users to specify minimum acceptable amounts for each withdrawn token
Direct transfers at L191 execute regardless of actual asset values relative to market prices
Attack Vector:
Attacker front-runs user's debond with large bond to manipulate _totalSupply and asset ratios
User's calculated _percSharesX96 yields fewer assets than expected
Attacker reverses position post-user-transaction through debond, profiting from manipulated ratios
The core vulnerability lies in the withdrawal process relying entirely on manipulable contract state without user-defined safety thresholds for asset outputs.
Internal Pre-conditions
debond function calculates withdrawals using real-time _totalSupply and _totalAssets
No minimum amount validation exists for individual token withdrawals
bond function allows arbitrary supply inflation without cooldown/limits
External Pre-conditions
Attacker has access to flash loan facilities
Index contains sufficient liquidity in underlying tokens (e.g., $1M TVL)
At least 2 tokens exist in the index with liquid markets
Attack Path
Victim initiates debond of 100,000 index tokens (worth $100k at fair value)
Attacker front-runs transaction with:
a. $500k flash loan
b. bond call injecting 500,000 index tokens via manipulated pricing
Victim suffers 33.4% immediate financial loss ($100k ➔ $66.6k) due to artificial supply inflation. Attack scales linearly with victim position size - a $1M debond under same conditions would yield $666k loss. Losses become permanent when attacker arbitrages manipulated assets against real markets.
PoC
No response
Mitigation
Implement mandatory slippage protection in the debond function through:
Minimum Output Parameters:
Add a uint256[] calldata minAmounts parameter for per-token minimums
Require withdrawn amounts ≥ specified minimums
Validation Layer:
for (uint256 i; i < indexTokens.length; ++i) {
uint256 debondAmount = ...; // Existing calculationrequire(debondAmount >= minAmounts[i], "Below minimum");
}
Crazy Cyan Worm
Medium
Missing Slippage Protection in
WeightedIndex.debond
Enables Flash Loan-Powered Sandwich AttacksSummary
The missing minimum output validation in
WeightedIndex.debond
will cause partial loss of funds for users withdrawing from the index as attackers can manipulate withdrawal ratios through flash loan-powered sandwich attacks. By front-running a user'sWeightedIndex.debond
transaction with a largeWeightedIndex.bond
operation funded by flash loans, attackers artificially inflate the index's total supply, reducing the victim's share percentage and withdrawn token amounts. This allows attackers to profit from the manipulated asset ratios while victims receive significantly less value than market rates.Root Cause
The
WeightedIndex.debond
function inWeightedIndex.sol#L185-L191
lacks critical slippage protection mechanisms, enabling sandwich attacks through:Manipulable Share Calculation:
_percSharesX96
ratio (L185) uses real-time_totalSupply
that attackers can inflate via front-runWeightedIndex.bond
calls_totalAssets
balances that can be altered through flash loan attacksAbsence of Minimum Output Checks:
Attack Vector:
debond
with largebond
to manipulate_totalSupply
and asset ratios_percSharesX96
yields fewer assets than expecteddebond
, profiting from manipulated ratiosThe core vulnerability lies in the withdrawal process relying entirely on manipulable contract state without user-defined safety thresholds for asset outputs.
Internal Pre-conditions
debond
function calculates withdrawals using real-time_totalSupply
and_totalAssets
bond
function allows arbitrary supply inflation without cooldown/limitsExternal Pre-conditions
Attack Path
a. $500k flash loan
b.
bond
call injecting 500,000 index tokens via manipulated pricing_totalSupply
inflated from 1M to 1.5M tokens_percSharesX96
becomes 6.66% instead of 10%debond
of 500k tokens:Impact
Victim suffers 33.4% immediate financial loss ($100k ➔ $66.6k) due to artificial supply inflation. Attack scales linearly with victim position size - a $1M debond under same conditions would yield $666k loss. Losses become permanent when attacker arbitrages manipulated assets against real markets.
PoC
No response
Mitigation
Implement mandatory slippage protection in the
debond
function through:Minimum Output Parameters:
uint256[] calldata minAmounts
parameter for per-token minimumsValidation Layer:
This matches the existing
bond
function's_amountMintMin
pattern, creating symmetric protection for deposit/withdrawal operations.The text was updated successfully, but these errors were encountered: