Submitted by marchev, also found by EV_om
https://github.com/code-423n4/2024-05-olas/blob/3ce502ec8b475885b90668e617f3983cea3ae29f/governance/contracts/VoteWeighting.sol#L155
The VoteWeighting within the protocol requires some sort of activity for nominees at least every 53 weeks to maintain its functionality properly. However, some nominees can be less active. Particularly when users lock their veOLAS for long periods (e.g., 4 years) and vote in a set-and-forget manner. 
Due to the current one-year lookbehind period, the nomineeRelativeWeight() function will break for less active nominees after one year (it will return 0), causing users with longer lock periods to essentially lose their voting power. This undermines the fairness and intended functionality of the protocol, as these users will no longer be able to influence governance or earn rewards despite their significant long-term commitment.
An attempt to address this issue with keepers would not be effective. A malicious user can create an arbitrarily large number of nominees. This would make iterating over all nominees on a regular basis to ensure checkpoints are made extremely gas-expensive, rendering the keepers model impractical and ineffective.
The vulnerability can be observed in the following scenario:
This issue can be traced to the code handling the lookbehind period for nominees, which does not retain historical data beyond 53 weeks:
https://github.com/code-423n4/2024-05-olas/blob/3ce502ec8b475885b90668e617f3983cea3ae29f/governance/contracts/VoteWeighting.sol#L267-L286
The following coded PoC demonstrates the issue. Add the following test case to VoteWeighting.js:
To mitigate this vulnerability, it is recommended to extend the lookbehind period to at least the maximum lock period plus one additional year. This approach is effectively implemented in Curves VotingEscrow, where the lookbehind period is 5 years while the maximum lock period is 4 years.
Furthermore, since the weight calculation is done on a per-nominee basis, there is isolation between the calculations for different nominees. This isolation ensures that issues with one nominee do not affect the calculations for others. If there are concerns related to reaching the block gas limit, the maximum number of weeks to iterate over can be made configurable.
Governance
kupermind (Olas) acknowledged and commented:
0xA5DF (judge) commented:
kupermind (Olas) commented:
0xA5DF (judge) commented:
Note: For full discussion, see here.
Olas mitigated
Varun_05 (warden) commented:
