Migration total supply reduction can be used to remove minority shareholders
The migration contract allows the new total supply to be set arbitrarily low, so when shares are calculated for contributors, rounding down can zero out minority shareholders' shares. An attacker or careless majority could set a very low new supply, causing minority contributors to lose their entire contribution when the migration is committed and a buyout starts.
Submitted by hyh, also found by Lambda and Treasure-Seeker
Vulnerability Details
As new total supply can be arbitrary, setting it significantly lower than current (say to 100 when it was 1e9 before) can be used to remove current minority shareholders, whose shares will end up being zero on a precision loss due to low new total supply value. This can go unnoticed as the effect is implementation based.
During Buyout the remaining shareholders are left with ETH funds based valuation and can sell the shares, but the minority shareholders that did contributed to the Migration, that could have other details favourable to them, may not realize that new shares will be calculated with the numerical truncation as a result of the new total supply introduction.
Setting the severity to Medium as this is a fund loss impact conditional on a user not understanding the particulars of the implementation.
Proof of Concept
Currently migrateFractions() calculates new shares to be transferred for a user as a fraction of her contribution:
// Calculates share amount of fractions for the new vault based on the new total supply
uint256 newTotalSupply = IVaultRegistry(registry).totalSupply(newVault);
uint256 shareAmount = (balanceContributedInEth * newTotalSupply) /
totalInEth;
If Bob the msg.sender is a minority shareholder who contributed to Migration with say some technical enhancements of the Vault, not paying attention to the total supply reduction, his share can be lost on commit():
// Starts the buyout process
IBuyout(buyout).start{value: proposal.totalEth}(_vault);
As commit() starts the Buyout, Bob will not be able to withdraw as both leave() and withdrawContribution() require INACTIVE state:
State required = State.INACTIVE;
if (current != required) revert IBuyout.InvalidState(required, current);
If Buyout be successful, Bob’s share can be calculated as zero given his small initial share and reduction in the Vault total shares.
For example, if Bob’s share together with the ETH funds he provided to Migration were cumulatively less than 1%, and new total supply is 100, he will lose all his contribution on commit() as migrateFractions() will send him nothing.
Recommended Mitigation Steps
Consider requiring that the new total supply should be greater than the old one:
proposal.oldFractionSupply = IVaultRegistry(registry).totalSupply(
_vault
);
proposal.newFractionSupply = _newFractionSupply;
+ require(proposal.newFractionSupply > proposal.oldFractionSupply, ""); // reference version
stevennevins (Fractional) confirmed
HardlyDifficult (judge) commented:
A migration that changes the supply can result in some users losing their expected share of funds. I agree with Medium risk here since the terms are known and the community could aim to reject the migration if they don’t agree with these changes.
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 migration contract allows the new total supply to be set to any value, including one much lower than the old supply, and the share calculation uses integer division that truncates to zero for small contributions.
Impact
Minority shareholders could lose their entire contribution if they do not notice the total supply reduction before the migration is committed.
What the attacker needed
A migration proposal with a much lower new total supply; minority shareholders contribute without noticing; the migration is committed
The fix
The migration should require that the new total supply is greater than the old one.
How it was found
- A migration proposal is created with a new total supply much lower than the current supply.
- Minority shareholders contribute to the migration without noticing the reduced total supply.
- The migration is committed, which starts a buyout and prevents withdrawal.
- The share calculation for each contributor uses the new low total supply and truncates their share to zero.
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.
When a vault is migrated to a new version, the total number of shares can be changed. If the new total is set very small, then when each person's share is recalculated, the maths rounds down and small holders can end up with zero shares. They lose the money they put in because the migration then starts a buyout and they cannot withdraw.
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.