Submitted by MiloTruck, also found by cccz, oyc109, VAD37, PP1004, SmartSek, minhquanym, unforgiven, berndartmueller, WatchPug, CertoraInc, and sorrynotsorry_
The attack vector and impact is the same as TOB-YEARN-003, where users may not receive shares in exchange for their deposits if the total asset amount has been manipulated through a large donation.
In BathToken.sol:569-571, the allocation of shares is calculated as follows:
An early attacker can exploit this by:
To avoid minting 0 shares, subsequent depositors have to deposit equal to or more than the amount transferred by the attacker. Otherwise, their deposits accrue to the attacker who holds the only share.
require(shares != 0, "No shares minted");
bghughes (Rubicon) confirmed and commented:
HickupHH3 (judge) commented:
