Submitted by carrotsmuggler, also found by GalloDaSballo and deadrxsezzz
When a user participates in the options system via TapiocaOptionBroker.sol, they mint an otap position in exchange for their tolp position. The time of creation is recorded, and the user is allowed to exercise the option only after a full epoch duration, which is a week.
The variable netDepositedForEpoch records how much liquidity the system expects to hold in any given epoch, and is used to calculate the rewards for the users. On calling participate, this variable is increased for the next epoch, and decreased on the expiration epoch.
The issue is this accounting is done via epoch, while the cooldown is accounted via block.timestamp. So if a user participates at the very beginning of an epoch, their option will be exercisable after 7 days, which is very close to the time when the epoch number can be incremented. If the user is able to call exerciseOption before the epoch number is incremented, they can even participate in the current epoch! This is because the epoch number has not yet been updated, but the EPOCH_DURATION has already passed.
In this scenario, the user gets access to the rewards of the very same epoch they participated in, which should be impossible. They can also cause the contract to run out of rewards, as they are claiming rewards they shouldnt be owed. The contract calculates rewards based on the current net deposit, which hasnt been updated yet since the epoch number hasnt been updated yet.
Thus the user can take out rewards based on the wrong netAmount, which can lead to other users not getting their rewards, since the eligibleAmount is decreased by users not owed any rewards.
The attack is carried out in the following steps. Lets assume the current epoch has JUST started, and is epoch 1. Lets assume the netAmount for this epoch is 100.
Since this allows users to collect rewards in the same epoch and break the accounting, and can be timed very effectively, this is a high severity issue.
The main issue is that the OneEpochCooldown is not measured in epochs and is measured in time instead, which will not necessarily always coincide. Can be fixed in a variety of methods:
Invalid Validation
0xRektora (Tapioca) confirmed via duplicate Issue #35
LSDan (judge) decreased severity to Medium
cryptotechmaker (Tapioca) commented via duplicate Issue #35:
