// Burn caller's party card. This will revert if caller is not the owner
// of the card.
burn(tokenId);
// Withdraw fair share of tokens from the party.
IERC20 prevToken;
for (uint256 j; j < withdrawTokens.length; ++j) {
IERC20 token = withdrawTokens[j];
// Prevent null and duplicate transfers.
if (prevToken >= token) revert InvalidTokenOrderError();
prevToken = token;
// Check if token is ETH.
if (address(token) == ETH_ADDRESS) {
// Transfer fair share of ETH to receiver.
uint256 amount = (address(this).balance * shareOfVotingPower) / 1e18;
if (amount != 0) {
payable(receiver).transferEth(amount);
}
} else {
// Transfer fair share of tokens to receiver.
uint256 amount = (token.balanceOf(address(this)) * shareOfVotingPower) / 1e18;
if (amount != 0) {
token.compatTransfer(receiver, amount);
}
}
}
The problem with this is that the governance NFT might also have tokens to claim() in the TokenDistributor. These cannot be claimed after the governance NFT has been burned.
The rage quitter cannot completely protect himself from this by calling claim() first, because the tokens might not yet have been distributed to the TokenDistributor until in a frontrun call to distribute() just before his rageQuit(). This way the rage quitter might be robbed of his fair share.
Recommended Mitigation Steps
Have rageQuit() call TokenDistributor.claim() before the governance NFT is burned.
Similar issues are considered M in C4. Loss of funds requires external requirements (user misses call to claim() or frontrun occurs).
Also, since the claim() only allows NFT owner to call, consider transferring the user’s NFT to the contract in rageQuit().
function claim(
DistributionInfo calldata info,
uint256 partyTokenId
) public returns (uint128 amountClaimed) {
// Caller must own the party token.
{
address ownerOfPartyToken = info.party.ownerOf(partyTokenId);
if (msg.sender != ownerOfPartyToken) {
revert MustOwnTokenError(msg.sender, ownerOfPartyToken, partyTokenId);
}
}
@cccz (judge) I think this issue should be more on the QA side as the sponsor clearly stated that rage quit may cause losses due to user inaction or mistake:
If a user intentionally or accidentally excludes a token in their ragequit, they forfeit that token and will not be able to claim it.
Similar to the described scenario, if a user forgets to call claim on the distributor before rage quitting, they will lose their share of tokens.
In this issue, even if the user does not make any mistake, they may suffer a loss because there may be a potential frontrun attack.
The original report as published on Code4rena, by d3e4. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
What is known
A medium-severity business logic bug in Party Protocol. Code4rena made it public on 23 June 2023. Found in the 2023-05-party audit contest (finding M-02), also found by 3 other wardens.
About Business logic
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.