Skip to content
DoS Audit finding Intermediate

Owner of a pool may prevent any taxes being withdrawn

The owner of a pool can set a malicious reward token that reverts when the global beneficiary tries to withdraw taxes, causing the entire withdrawTaxes transaction to fail and permanently locking the taxed tokens in the contract.

AuditsAreUS Follow

Originally disclosed on Code4rena

Submitted by AuditsAreUS, also found by IllIllI

It is possible for the owner of a pool to prevent any taxes being withdrawn by the globalBeneficiary. The impact is the taxed tokens will be permanently locked in the contract and withdrawTaxes() will not be callable for that poolId.

Proof of Concept

The attack works by setting one of the rewardTokenAddresses to a malicious contract during addPool(). The malicious contract is set such that it will revert on the call pool.rewardTokens[i]).transfer(globalBeneficiary, tax) if an only if the to address is `globalBeneficiary.

The result of this attack is that if one reward transfer fails then entire withdrawTaxes() transaction will revert and no taxes can be claimed. However, the pool will function correctly for all other users.

    function withdrawTaxes(uint poolId) external {
        Pool storage pool = pools[poolId];
        require(pool.id == poolId, 'Uninitialized pool');

        bool success = true;
        for (uint i = 0; i < pool.rewardTokens.length; i++) {
            uint tax = taxes[poolId][i];
            taxes[poolId][i] = 0;
            success = success && IERC20(pool.rewardTokens[i]).transfer(globalBeneficiary, tax);
        }
        require(success, 'Token transfer failed');
    }

Recommended Mitigation Steps

There are a few mitigations to this issue.

The first is for the withdrawTaxes() function to take both poolId and rewardIndex as a parameters to allowing the tax beneficiary to only withdraw from certain reward tokens in the pool. This would allow the beneficiary to withdraw from all reward tokens except malicious ones.

The second mitigation is to implement a try-catch condition around the withdrawal of reward tokens. In the catch statement re-instate the taxes[poolId][i] = tax if the transfer fails. Alternatively just skip the reward tokens if the transfer fails though this would be undesirable if a token is paused for some reason.

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

Valid, will probably do try-catch.

illuzen (FactoryDAO) resolved:

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

Justin Goro (judge) decreased severity to Medium and commented:

Downgraded: deposited funds not at risk but value leakage occurs.


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

The withdrawTaxes function uses a single success flag and a require that reverts the entire transaction if any token transfer fails, without handling individual failures.

What the attacker needed

Attacker is the pool owner; Attacker can add a malicious reward token

The fix

The withdrawTaxes function should be modified to allow withdrawal per reward token or to use try-catch so that a single failed transfer does not block all others.

How it was found

  1. The pool owner calls addPool() and sets one of the rewardTokenAddresses to a malicious contract.
  2. The malicious contract is designed to revert when transfer is called with the globalBeneficiary as the recipient.
  3. When withdrawTaxes() is called, it loops over reward tokens and attempts to transfer tax to globalBeneficiary.
  4. The transfer to the malicious token reverts, causing the success flag to become false.
  5. The require(success) check fails, reverting the entire withdrawTaxes() transaction.

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.

A pool owner can add a fake token that refuses to send money to the tax collector. Because the withdrawal function tries to send all tokens at once, one failure stops the whole process, so the tax money gets stuck forever.

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.