Platform: Code4rena
Start Date: 04/05/2022
Pot Size: $50,000 DAI
Total HM: 24
Participants: 71
Period: 5 days
Judge: Justin Goro
Total Solo HM: 14
Id: 119
League: ETH
Rank: 68/71
Findings: 1
Award: $3.18
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: MaratCerby
Also found by: 0x1337, 0x52, 0xYamiDancho, AuditsAreUS, CertoraInc, Dravee, GimelSec, IllIllI, PPrieditis, Ruhum, TrungOre, VAD37, berndartmueller, cccz, csanuragjain, defsec, hickuphh3, horsefacts, hyh, jayjonah8, kenzo, leastwood, mtz, p4st13r4, reassor, throttle, wuwe1, ych18
3.1753 DAI - $3.18
https://github.com/code-423n4/2022-05-factorydao/blob/main/contracts/PermissionlessBasicPoolFactory.sol#L249-L254 https://github.com/code-423n4/2022-05-factorydao/blob/main/contracts/PermissionlessBasicPoolFactory.sol#L248-L254 https://github.com/code-423n4/2022-05-factorydao/blob/main/contracts/PermissionlessBasicPoolFactory.sol#L265-L271
Reward token transfers are done in 3 functions withdraw
, withdrawExcessRewards
and withdrawTaxes
.
If transfer of any reward token returns False or reverts for whatever reason these functions completely fail.
This can lead to loss of funds for 3 kinds of users. 1. Depositers can lose their deposit and any reward tokens they are entitled to. 2. The globalBeneficiary
could lose the taxes for a pool that they are entitled to. 3. The pool funder could lose any excess reward tokens they have used to fund a pool.
All of the above cases are possible if a token fails to transfer. But the first two, depositers and globalBenficiary
,can be harmed by an intentionally malicious pool funder. This malicious funder can create a malicious token contract and add that token to a pool. This token contract can fail to transfer when the attacker toggles a switch, causing the globalBeneficiary
not to be able to receive taxes for that pool, and more importantly for depositers to lose their deposit and any reward tokens they are entitled to.
Note that pool funders can also fall victim to this problem if one of the reward tokens accidentally malfunctions. Because this is less likely than a token intentionally malfunctioning, it is a less serious concern.
depositToken
into evil pool.globalBenficiary
depositToken
from evil pool. The transfer of the the depositToken
and WETH would succeed but because the transfer of the evil token reverts, the entire call to withdraw
reverts and the victim gets back nothing.globalBeneficiary
cannot withdraw any taxes from that pool.This flaw can harm depositers, the globalBeneficiary
and pool funders.
The harm is most serious to depositers who can even lose their deposit. It is less serious to the globalBeneficary
who can lose taxes for a single pool and it is least harmful to pool funders who will lose excess deposits (but a malicious pool funder cannot use this to attack them, harm can only result if one of the token genuinely fails to transfer not accidentally).
There are a number of ways to mitigate this problem.
emergencyWithdraw
function that allows depositers to withdraw their depositToken
without
receiving any reward tokens.withdraw
(for rewards), withdrawTaxes
, and withdrawExcessTokens
that allow callers to specify which token they want to withdraw. This way they can get the functioning tokens they are entitled to while only losing the malfunctioning token (there is no way to prevent theft of an attacker controlled token anyway).#0 - illuzen
2022-05-11T09:41:39Z
Duplicate #34
#1 - gititGoro
2022-06-14T02:00:42Z
Changing severity due pool isolation, rewards tokens represent leakage not lost funds and because transfer of deposited funds would fail on deposit.