Open code423n4 opened 2 years ago
We can enforce whitelists in the FE. Parties will be educated against creating distributions for tokens with weird balance mechanics.
Agree this may be better addressed on the frontend. These tokens would cause issues with many protocols like this. I believe this is low risk. Converting this into a QA report for the warden.
Lines of code
https://github.com/PartyDAO/party-contracts-c4/blob/3896577b8f0fa16cba129dc2867aba786b730c1b/contracts/distribution/TokenDistributor.sol#L341-L342
Vulnerability details
Impact
There are weird erc20 tokens out there that can modify their
balanceOf(distributor)
outside of transfers. More information here.Because distributions in
TokenDistributior
are allowed for arbitrary, user-provided erc20, we should assume that sooner or later someone will create a distribution with such a weird erc20 token.If a token increases its
balanceOf(distributor)
outside of transfers, then this additional amount of tokens can be stolen by anyone.If a token decreases its
balanceOf(distributor)
outside of transfers, then at least some users will receive less than their fair share from distributions of this token.Proof of Concept
Add this test cases to TokenDistributorUnit.t.sol file:
it’s worth noting that if
supplySecondDistribution < burnedSupply
thencreateErc20Distribution
will revert because of underflow in this line of code.Also if
balanceOf(distributor)
decreases outside of transfers, then this balance might become smaller thanDistributionInfo.memberSupply
and the distributor contract becomes insolvent. In such case, users last to claim their shares will receive smaller or even zero shares because of this line of code.Tools Used
Foundry
Recommended Mitigation Steps
It’s probably impossible to prevent weird tokens from being sent to
GovernanceParty
contracts. However, it might be a good idea to create a whitelist of supported tokens forTokenDistributor
.If such a whitelist is added, make sure that weird erc20 sent to party contracts are not stuck and can still be recovered e.g. by creating a proposal with arbitrary calls.