Skip to content
DoS Audit finding Intermediate

Malicious token reward could disable withdrawals

The withdraw function in PermissionlessBasicPoolFactory requires each reward token transfer to succeed before returning the deposit. If a reward token is malicious or pausable and reverts on transfer, users' deposits become stuck in the contract.

shenwilly Follow

Originally disclosed on Code4rena

Submitted by shenwilly, also found by 0xYamiDancho, hickuphh3, hubble, kenzo, and leastwood

PermissionlessBasicPoolFactory.withdraw requires each reward token transfers to succeed before withdrawing the deposit. If one of the reward token is a malicious/pausable contract that reverts on transfer, unaware users that deposited into this pool will have their funds stuck in the contract.

Recommended Mitigation Steps

Add an emergencyWithdraw function that ignores failed reward token transfers.

illuzen (FactoryDAO) confirmed and commented:

This is explicitly acknowledged in the contract comments, malicious reward tokens render the pool malicious, there is no way to get around that, but the emergencyWithdraw idea is good

illuzen (FactoryDAO) commented:

Technically duplicate, but mitigation is better here.

illuzen (FactoryDAO) resolved:

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

ksk2345 (warden) commented:

  1. User Funds are at loss so severity of this issue is High. Please check the descriptions in the duplicate IssueIDs : #191, #145, and #106 (marked wrongly as dup of M13)
  2. IssueId #192 and #246 are wrongly marked as dup of M02. The root cause is malicious rewardToken, but the impact is different than that of M02, and also the code fix for the impact will be different. M02 talks of impact on loss of user deposits and the fix will be in withdraw function. While these two Issues impact on globalBeneficiary not able to withdraw rewards, the fix will be in withdrawTaxes() function. Hence, these two issues needs to be separated into a New Medium Issue.

Justin Goro (judge) commented:

@ksk2345 - I really do sympathize with your point of view. I think you made two good points. Here’s the thing, though: When assessing these issues, it’s very important to take sponsor’s intent into account. That’s what makes humans necessary in C4 (for now). Sufficiently powerful software can form a graph of vulnerabilities and draw inferences. Our job is to figure out if these vulnerabilities matter and to what extent.

First to the broader point of linking duplicates, whether blocking users or taxes, the vector is via a malicious pool creator in the form of a reward token. The reason this matters is because the Factorydao pools can be permissionlessly created and completely ignored by users. They are analogous to Uniswap pools. Sure, someone could create a malicious token pair in Uniswap but since all pairs are opt-in and can be routed around, the use of this pair requires explicit consent from the end user.

If we bear in mind that end user involvement is consensual and that this is communicated to the users and that nothing can be hidden on Ethereum then it follows that we can umbrella these issues not as malicious tokens or withdrawal and tax vulnerabilities but pool creators trying to game the code while relying on social engineering to funnel unsuspecting users through these channels (scam).

digression on duplicates On a broader issue of duplicates, I notice a similar theme arising when duplicate labels are challenged so I’d just like to clarify how I grouped duplicates:

For most of the duplicate disputes, it was “the issue reported the same but the fix was different.” If the issue is invalid, however, then the fix is kind of irrelevant which is why I grouped those all as the same issue. If the issue is the same but the fixes different, then I grouped them if the fixes were qualitatively similar. If there was one amongst them that provided the best fix, this would be the original in the set.


The original report as published on Code4rena, by shenwilly. 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 withdraw function performs reward token transfers before returning the deposit, and a revert in any reward transfer blocks the entire withdrawal.

Impact

Users who deposited into a pool with a malicious or pausable reward token could have their funds permanently stuck, as the sponsor acknowledged that malicious reward tokens render the pool malicious.

What the attacker needed

Pool creator adds a malicious reward token; user deposits into that pool

The fix

An emergencyWithdraw function that ignores failed reward token transfers was added to mitigate the issue.

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 smart contract lets people deposit funds and earn rewards in other tokens. When they try to take back their deposit, the contract first sends out any pending rewards. If one of those reward tokens is designed to always fail on transfer, the whole withdrawal fails, so the deposit cannot be retrieved.

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 shenwilly

View all

12 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.