Skip to content
DoS Audit finding Intermediate

`_distribute()` function in RFPSimpleStrategy contract has wrong requirement causing DOS

The _distribute function checks the full proposal bid against the remaining pool amount, but the pool amount decreases after each milestone payment. After the first milestone, the check fails for subsequent milestones, causing a denial of service when trying to pay the recipient.

0xarno Follow with 0xdeadbeef, 0xkaden and 21 others

Originally disclosed on Sherlock

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

Found by

0xarno, 0xdeadbeef, 0xkaden, BenRai, GimelSec, HHK, KingNFT, WATCHPUG, ZdravkoHr., ace13567, alexxander, dany.armstrong90, fishgang, grearlake, honeymewn, jkoppel, lemonmon, nobody2018, osmanozdemir1, p0wd3r, pengun, pontifex, qbs, tnquanghuy0512

Vulnerability Detail

The function _distribute():

Solidity
    function _distribute(address[] memory, bytes memory, address _sender)
        internal
        virtual
        override
        onlyInactivePool
        onlyPoolManager(_sender)
    {
        ...

        IAllo.Pool memory pool = allo.getPool(poolId);
        Milestone storage milestone = milestones[upcomingMilestone];
        Recipient memory recipient = _recipients[acceptedRecipientId];

        if (recipient.proposalBid > poolAmount) revert NOT_ENOUGH_FUNDS();

        uint256 amount = (recipient.proposalBid * milestone.amountPercentage) / 1e18;

        poolAmount -= amount;//<@@ NOTICE the poolAmount get decrease over time

        _transferAmount(pool.token, recipient.recipientAddress, amount);

        ...
    }

Let's suppose this scenario:

  • Pool manager funding the contract with 100 token, making poolAmount variable equal to 100
  • Pool manager set 5 equal milestones with 20% each
  • Selected recipient's proposal bid is 100, making recipients[acceptedRecipientId].proposalBid variable equal to 100
  • After milestone 1 done, pool manager pays recipient using distribute(). Value of variables after: poolAmount = 80 ,recipients[acceptedRecipientId].proposalBid = 100
  • After milestone 2 done, pool manager will get DOS trying to pay recipient using distribute() because of this line:
Solidity
if (recipient.proposalBid > poolAmount) revert NOT_ENOUGH_FUNDS();

Impact

This behaviour will cause DOS when distributing the 2nd milestone or higher

Code Snippet

https://github.com/sherlock-audit/2023-09-Gitcoin/blob/6430c8004017e96ae2f5aac365bdefd0b6eeea72/allo-v2/contracts/strategies/rfp-simple/RFPSimpleStrategy.sol#L417C1-L450C6

Tool used

Manual Review

Recommendation

Solidity
-        if (recipient.proposalBid > poolAmount) revert NOT_ENOUGH_FUNDS();
+        if ((recipient.proposalBid * milestone.amountPercentage) / 1e18 > poolAmount) revert NOT_ENOUGH_FUNDS();

Discussion

jacksanford1

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

jack-the-pug

Fixed.

The original report as published on Sherlock, by 0xarno. 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

Root cause

The requirement compares the full proposal bid to the remaining pool amount instead of the amount needed for the current milestone.

Impact

This behaviour will cause DOS when distributing the 2nd milestone or higher.

What the attacker needed

Pool manager funds contract; multiple milestones set; recipient proposal bid equals pool amount

How it was found

  1. Pool manager funds the contract with 100 tokens, setting poolAmount to 100.
  2. Pool manager sets 5 equal milestones with 20% each.
  3. Selected recipient's proposal bid is 100.
  4. After milestone 1, pool manager calls distribute(), reducing poolAmount to 80.
  5. After milestone 2, pool manager tries to call distribute() but it reverts with NOT_ENOUGH_FUNDS.

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.

This is a smart contract bug where a payment function incorrectly checks if there is enough money left. The check compares the total promised amount to the remaining pool, but the pool shrinks after each payment, so later payments are blocked even though there is enough for the next instalment.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by 0xarno

View all

3 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.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.