Attacker can frontrun contributions to the crowdsale to become default delegate
for new users
#226
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-418
edited-by-warden
insufficient quality report
This report is not of sufficient quality
satisfactory
satisfies C4 submission criteria; eligible for awards
Lines of code
https://github.com/code-423n4/2023-10-party/blob/b23c65d62a20921c709582b0b76b387f2bb9ebb5/contracts/crowdfund/InitialETHCrowdfund.sol#L235
https://github.com/code-423n4/2023-10-party/blob/b23c65d62a20921c709582b0b76b387f2bb9ebb5/contracts/party/PartyGovernanceNFT.sol#L166
Vulnerability details
When calling
contributeFor
a user can contribute ETH for another user and mint him a party card. If the recipient didn't have adelegate
then it will use thedelegate
passed by the caller.If the recipient later on decide to contribute by himself calling
contribute()
thedelegate
will be updated with the one he passed.But this update only happens at the InitialETHCrowdfund contract and not at the party level.
The party will only update the
delegate
on the first mint and then reuse the internal one every time.Eventually if a user wants to change his delegate he will have to call
delegateVotingPower()
on the party.Impact
An attacker could frontrun contributions by calling
contributeFor()
for the user about to contribute and use the minimum contribution allowed by the party and set himself asdelegate
.This would result in the
contribute()
transaction of the user to delegate the new voting power to the attacker and not the passeddelegate
.If users don't check that their delegate voting power increased after contributing, an attacker could grow in voting power and submit malicious proposals once the crowdfunding is over leaving the host veto power as only protection.
Users might be notified and call
delegateVotingPower()
to update theirdelegate
but it'll be too late if the proposal has been submitted as it uses the voting power snapshot taken at the time of the proposal submission.Proof of Concept
Here is a POC that can be used in the
InitialETHCrowdfund.t.sol
using the commandforge test --match-test test_frontrunWithcontributeForToBecomeDelegate
.Tools Used
Manual review.
Recommended Mitigation Steps
Update the
PartyGovernanceNFT.mint()
function to overwrite thedelegate
when the contributor is themsg.sender
inInitialETHCrowdfund_contribute()
.Assessed type
MEV
The text was updated successfully, but these errors were encountered: