`_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():
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
poolAmountvariable equal to 100 - Pool manager set 5 equal milestones with 20% each
- Selected recipient's proposal bid is 100, making
recipients[acceptedRecipientId].proposalBidvariable 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:
if (recipient.proposalBid > poolAmount) revert NOT_ENOUGH_FUNDS();
Impact
This behaviour will cause DOS when distributing the 2nd milestone or higher
Code Snippet
Tool used
Manual Review
Recommendation
- 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.
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
- Pool manager funds the contract with 100 tokens, setting poolAmount to 100.
- Pool manager sets 5 equal milestones with 20% each.
- Selected recipient's proposal bid is 100.
- After milestone 1, pool manager calls distribute(), reducing poolAmount to 80.
- 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.