Submitted by 0x73696d616f, also found by mert_eren, oakcobalt, SpicyMeatball, Tricko, 0xComfyCat, QiuhaoLi, Team_Rocket, Yanchuan, immeas, GREY-HAWK-REACH, th13vn, 0xCiphky (1, 2), ltyu, deadrxsezzz, nonseodion, lanrebayode77, 0xDetermination, popular00, and kaden
https://github.com/code-423n4/2023-08-verwa/blob/main/src/GaugeController.sol#L211 https://github.com/code-423n4/2023-08-verwa/blob/main/src/VotingEscrow.sol#L356
Delegate mechanism in VotingEscrow allows infinite votes in vote_for_gauge_weights() in the GaugeController. Users can then, for example, claim more tokens in the LendingLedger in the market that they inflated the votes on.
VotingEscrow has a delegate mechanism which lets a user delegate the voting power to another user.
The GaugeController allows voters who locked native in VotingEscrow to vote on the weight of a specific gauge.
Due to the fact that users can delegate their voting power in the VotingEscrow, they may vote once in a gauge by calling vote_for_gauge_weights(), delegate their votes to another address and then call again vote_for_gauge_weights() using this other address.
A POC was built in Foundry, add the following test to GaugeController.t.sol:
Vscode, Foundry
The vulnerability comes from the fact that the voting power is fetched from the current timestamp, instead of n blocks in the past, allowing users to vote, delegate, vote again and so on. Thus, the voting power should be fetched from n blocks in the past.
Additionaly, note that this alone is not enough, because when the current block reaches n blocks in the future, the votes can be replayed again by having delegated to another user n blocks in the past. The exploit in this scenario would become more difficult, but still possible, such as: vote, delegate, wait n blocks, vote and so on. For this reason, a predefined window by the governance could be scheduled, in which users can vote on the weights of a gauge, n blocks in the past from the scheduled window start.
alcueca (Judge) commented:
 OpenCoreCH (veRWA) confirmed on duplicate finding 86
