A user can front-run profit distributions in the DAO to gain immediate profits without meaningful participation. The attack allows the user to join right before a profit distribution, gain a share of the profits, and exit immediately with those profits.
The vulnerability exists in the interaction between joinDAO
function and sendProfit
.
When a user joins a DAO, they can immediately participate in profit distributions:
Immediately after joining, they get a full share of any profit distribution:
Let's create a PoC so we can validate the following scenario:
Attacker notices a large profit distribution will be made by a certain DAO with 2 members, so he does the following:
Front-run the profit distribution transaction and:
Join the DAO that will receive the profits, paying the fees to enter, i.e: 1 ETH spending
Distribution of 10 ETH is done to the DAO members.
At this moment attacker receives 33.3% of the profits.
Claim and exit immediately with the profit.
Net profit: 2.33 ETH (3.33 ETH profit - 1 ETH join cost)
Install foundry: foundryup
then forge init --force
In the test folder create the file MembershipFactory.t.sol
and paste the code below:
Then run: forge test --match-test test_StealProfitFromDaoMembers -vv
Output:
The attacker exploited the DAO and stole 3.3e18
within 1 second of participation. Legitimate participants with actual stakes suffered financial losses as a result.
Attackers can join just before profits are distributed to unfairly claim a share.
Legitimate members receive less profit because attackers dilute the distribution.
In a nutshell, loss of funds with high probability.
Manual Review
Hatehat & Foundry
Add a vesting period for profit participation. New members should wait a certain time before being eligible for profit distribution.
An improved approach is to distribute profits proportionally based on the duration each user has been a member of the DAO.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.