Submitted by shw
The getPoolShareWeight function returns a users pool share weight by calculating how many SPARTAN the users LP tokens account for. However, this approach is vulnerable to flash loan manipulation since an attacker can swap a large number of TOKEN to SPARTAN to increase the number of SPARTAN in the pool, thus effectively increasing his pool share weight.
According to the implementation of getPoolShareWeight, a users pool share weight is calculated by uints * baseAmount / totalSupply, where uints is the number of users LP tokens, totalSupply is the total supply of LP tokens, and baseAmount is the number of SPARTAN in the pool. Thus, a users pool share weight is proportional to the number of SPARTAN in the pool. Consider the following attack scenario:
Referenced code:
Utils.sol#L46-L50,
Utils.sol#L70-L77,
DaoVault.sol#L44-L56,
Dao.sol#L201, and
Dao.sol#L570.
A possible mitigation is to record the current timestamp when a users weight in the DaoVault or BondVault is recalculated and force the new weight to take effect only after a certain period, e.g., a block time. This would prevent the attacker from launching the attack since there is typically no guarantee that he could arbitrage the WBNB back in the next block.
SamusElderg (Spartan) confirmed and disagreed with severity:
ghoul-sol (judge) commented:
