Skip to content
DoS Audit finding Intermediate

DoS: Blacklisted user may prevent withdrawExcessRewards()

A blacklisted user cannot withdraw their funds because the token transfer fails, and the contract requires all deposits to be withdrawn before the owner can call withdrawExcessRewards. This locks the owner's excess rewards and potentially other users' funds.

AuditsAreUS Follow

Originally disclosed on Code4rena

Submitted by AuditsAreUS

https://github.com/code-423n4/2022-05-factorydao/blob/db415804c06143d8af6880bc4cda7222e5463c0e/contracts/PermissionlessBasicPoolFactory.sol#L242-L256

https://github.com/code-423n4/2022-05-factorydao/blob/db415804c06143d8af6880bc4cda7222e5463c0e/contracts/PermissionlessBasicPoolFactory.sol#L224-L234

Impact

If one user becomes blacklisted or otherwise cannot be transferred funds in any of the rewards tokens or the deposit token then they will not be able to call withdraw() for that token.

The impact of one user not being able to call withdraw() is that the owner will now never be able to call withdrawExcessRewards() and therefore lock not only the users rewards and deposit but also and excess rewards attributed to the owner.

Thus, one malicious user may deliberately get them selves blacklisted to prevent the owner from claiming the final rewards. Since the attacker may do this with negligible balance in their deposit() this attack is very cheap.

Proof of Concept

It is possible for IERC20(pool.rewardTokens[i]).transfer(receipt.owner, transferAmount); to fail for numerous reasons. Such as if a user has been blacklisted (in certain ERC20 tokens) or if a token is paused or there is an attack and the token is stuck.

This will prevent withdraw() from being called.

        for (uint i = 0; i < rewards.length; i++) {
            pool.rewardsWeiClaimed[i] += rewards[i];
            pool.rewardFunding[i] -= rewards[i];
            uint tax = (pool.taxPerCapita * rewards[i]) / 1000;
            uint transferAmount = rewards[i] - tax;
            taxes[poolId][i] += tax;
            success = success && IERC20(pool.rewardTokens[i]).transfer(receipt.owner, transferAmount);
        }

        success = success && IERC20(pool.depositToken).transfer(receipt.owner, receipt.amountDepositedWei);
        require(success, 'Token transfer failed');

Since line 245 of withdrawExcessRewards() requires that require(pool.totalDepositsWei == 0, 'Cannot withdraw until all deposits are withdrawn');, if one single user is unable to withdraw then it is impossible for the owner to claim the excess rewards and they are forever stuck in the contract.

Recommended Mitigation Steps

Consider allowing withdrawExcessRewards() to be called after a set period of time after the pool end if most users have withdrawn or some similar criteria.

illuzen (FactoryDAO) confirmed, disagreed with severity and commented:

Kind of a duplicate, but I like this angle better. However, malicious token contracts are explicitly considered in the contract as an acceptable risk. Will probably just wrap transfers in a try catch

illuzen (FactoryDAO) resolved:

https://github.com/code-423n4/2022-05-factorydao/pull/2

Justin Goro (judge) commented:

Maintaining severity as deposit tokens at risk.


The original report as published on Code4rena, by AuditsAreUS. 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.

How it worked

Root cause

Likely the contract uses a single success flag for all token transfers in withdraw() and requires that flag to be true, so any failed transfer reverts the whole withdrawal and prevents totalDepositsWei from reaching zero, which is a precondition for withdrawExcessRewards().

Impact

A malicious user can cheaply lock the owner's excess rewards and potentially other users' funds by getting blacklisted, though the team considers malicious token contracts an acceptable risk and plans to wrap transfers in a try-catch.

What the attacker needed

Attacker has a deposit in the pool; attacker gets blacklisted by a reward or deposit token

The fix

The team resolved this by wrapping transfers in a try-catch, as indicated in the linked pull request.

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.

In a smart contract, a function can fail if a token transfer to a user is blocked, for example because the user is blacklisted by the token. If the contract requires every user to withdraw before the owner can take their share, one blocked user can stop the owner from ever getting their funds.

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.

More by AuditsAreUS

View all

9 more disclosed reports, best first.

More from FactoryDAO contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.