Skip to content
Smart contracts Audit finding Intermediate

Exponential Inflation of Voice Credits in Quadratic Voting Strategy

The quadratic voting strategy contract incorrectly accumulates voice credits by adding the previous total to itself, causing exponential growth instead of linear. An attacker could allocate credits in multiple transactions to inflate their voting power and skew the matching pool distribution.

0x00ffDa Follow with 0x3b, 0xRstStn and 43 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-09-Gitcoin-judging/issues/48

Found by

0x00ffDa, 0x3b, 0xRstStn, 0xarno, 0xbepresent, 0xc0ffEE, 0xdeadbeef, 0xkaden, 0xpoolbaer, Arz, AsenXDeth, BenRai, GimelSec, HChang26, HHK, KingNFT, Kow, Topmark, WATCHPUG, ZdravkoHr., ace13567, alexxander, ashirleyshe, ast3ros, chaduke, coffiasd, dany.armstrong90, detectiveking, honeymewn, jah, jkoppel, jovi, lemonmon, lil.eth, nobody2018, osmanozdemir1, pengun, pontifex, rvierdiiev, seeques, shtesesamoubiq, simon135, tnquanghuy0512, toshii, trachev, twcctop

Vulnerability Detail

In the given code snippet, we observe a potential issue in the way voice credits are being accumulated for each recipient. The specific lines of code in question are:

Solidity
function _qv_allocate(
        ...
    ) internal onlyActiveAllocation {
        ...
        uint256 creditsCastToRecipient = _allocator.voiceCreditsCastToRecipient[_recipientId];
        ...
        // get the total credits and calculate the vote result
        uint256 totalCredits = _voiceCreditsToAllocate + creditsCastToRecipient;
        ...
        //E update allocator mapping voice for this recipient
        _allocator.voiceCreditsCastToRecipient[_recipientId] += totalCredits; //E @question should be only _voiceCreditsToAllocate
        ...
    }

We can see that at the end :

Solidity
_allocator.voiceCreditsCastToRecipient[_recipientId] = _allocator.voiceCreditsCastToRecipient[_recipientId] + _voiceCreditsToAllocate +  _allocator.voiceCreditsCastToRecipient[_recipientId];

Here, totalCredits accumulates both the newly allocated voice credits (_voiceCreditsToAllocate) and the credits previously cast to this recipient (creditsCastToRecipient). Later on, this totalCredits is added again to voiceCreditsCastToRecipient[_recipientId], thereby including the previously cast credits once more

Proof of Concept (POC):

Let's consider a scenario where a user allocates credits in three separate transactions:

  1. Transaction 1: Allocates 5 credits
  • creditsCastToRecipient initially is 0
  • totalCredits = 5 (5 + 0)
  • New voiceCreditsCastToRecipient[_recipientId] = 5
  1. Transaction 2: Allocates another 5 credits
  • creditsCastToRecipient now is 5 (from previous transaction)
  • totalCredits = 10 (5 + 5)
  • New voiceCreditsCastToRecipient[_recipientId] = 15 (10 + 5)
  1. Transaction 3: Allocates another 5 credits
  • creditsCastToRecipient now is 15
  • totalCredits = 20 (5 + 15)
  • New voiceCreditsCastToRecipient[_recipientId] = 35 (20 + 15)

From the above, we can see that the voice credits cast to the recipient are exponentially growing with each transaction instead of linearly increasing by 5 each time

Impact

Exponential increase in the voice credits attributed to a recipient, significantly skewing the results of the voting strategy( if one recipient receive 15 votes in one vote and another one receive 5 votes 3 times, the second one will have 20 votes and the first one 15) Over time, this could allow for manipulation and loss of trust in the voting mechanism and the percentage of amount received by recipients as long as allocations are used to calculate the match amount they will receive from the pool amount.

Code Snippet

https://github.com/allo-protocol/allo-v2/blob/main/contracts/strategies/qv-base/QVBaseStrategy.sol#L529

Tool used

Manual Review

Recommendation

Code should be modified to only add the new voice credits to the recipient's tally. The modified line of code should look like:

Solidity
_allocator.voiceCreditsCastToRecipient[_recipientId] += _voiceCreditsToAllocate;

Discussion

MLON33

https://github.com/allo-protocol/allo-v2/pull/338

jack-the-pug

Fixed

The original report as published on Sherlock, by 0x00ffDa. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Impact

The exponential increase in voice credits could significantly skew voting results and allow manipulation of the matching pool distribution, potentially eroding trust in the voting mechanism.

What the attacker needed

Ability to allocate voice credits

How it was found

  1. Allocate 5 credits to a recipient; the stored total becomes 5.
  2. Allocate another 5 credits; the stored total becomes 15.
  3. Allocate another 5 credits; the stored total becomes 35.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

In a voting system, each person gets a certain number of credits to allocate to projects. The code that tracks how many credits a project has received made a mistake: it added the old total to the new total, so the number grew much faster than it should. This meant someone could give a small number of credits repeatedly and end up with a huge influence on the vote.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by 0x00ffDa

View all

8 more disclosed reports, best first.

More from Allo V2

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.