Submitted by 0xA5DF
Lines: https://github.com/code-423n4/2022-07-fractional/blob/8f2697ae727c60c93ea47276f8fa128369abfe51/src/modules/Buyout.sol#L118-L138
https://github.com/code-423n4/2022-07-fractional/blob/8f2697ae727c60c93ea47276f8fa128369abfe51/src/modules/Buyout.sol#L156-L165
In the buyout module when a buyout starts - the module stores the fractionPrice, and when a user wants to buy/sell fractions the fractionPrice is loaded from storage and based on that the module determines the price of the fractions.
The issue here is that the total supply might change between the time the buyout start till the buy/sell time, and the fractionPrice stored in the module might not represent the real price anymore.
Currently there are no module that mint/burn supply at the time of buyout, but considering that Fractional is an extendible platform - Fractional might add one or a user might create his own module and create a vault with it.
An example of an innocent module that can change the total supply - a split module, this hypothetical module may allow splitting a coin (multiplying the balance of all users by some factor, based on a vote by the holders, the same way QuickSwap did at March)).
If that module is used in the middle of the buyout, that fraction price would still be based on the old supply.
Consider the following scenario
Heres a test (added to the test/Buyout.t.sol file) demonstrating this scenario (test passes = the bug exists).
Trying to create a proof for minting was too much time-consuming, so I just disabled the proof check in Vault.execute in order to simulate the split:
Foundry
Calculate fraction price at the time of buy/sell according to the current total supply:
(Disclosure: this is based on a solution I made for a different bug).
HardlyDifficult (judge) decreased severity to QA and commented:
0xA5DF (warden) commented:
HardlyDifficult (judge) increased severity to Medium and commented:
stevennevins (Fractional) commented:
