The swap rate calculation in VaultRouterBranch::getIndexTokenSwapRate and VaultRouterBranch::getVaultAssetSwapRate depends on getVaultCreditCapacity. When credit capacity is low, users receive a large number of index tokens per unit of collateral. This creates an issue. When credit capacity is low, a user will get too many tokens for a deposit. As a result other user when they redeem shares, will get very less tokens
getVaultAssetSwapRate calculates sharesOut by multiplying assetsIn with current total supply of index token and then dividing by vault's current credit capacity
When totalAssetsMinusVaultDebt is low, the sharesOut will be high
getIndexTokenSwapRate calculates assetsOut by multiplying sharesIn with total credit capacity of the vault, then dividing by total supply of index token
A attacker can time his deposit, when vault's credit capacity is low, he will deposit, getting a lot of index token. And even when the vault's credit capacity becomes normal again, the getIndexTokenSwapRate will not return high value rather will return very low amount for those who deposited when totalAssetsMinusVaultDebt was normal due to division by very big total supply.
Paste this code in test/contest/SharesTest.t.sol and run: forge test --mt testSharesOut -vv
Attacker gets more tokens than they deposited
User will lose tokens due to division by very large total supply
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.