FactoryDAO contest - rajatbeladiya's results

The DAO that builds DAOs.

General Information

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

FactoryDAO

Findings Distribution

Researcher Performance

Rank: 26/71

Findings: 3

Award: $218.85

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: reassor

Also found by: IllIllI, VAD37, hyh, kenzo, leastwood, rajatbeladiya, ych18

Labels

bug
duplicate
2 (Med Risk)
sponsor confirmed

Awards

105.1961 DAI - $105.20

External Links

Lines of code

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

Vulnerability details

Impact

All rewards calculations are referring to 18 decimals token. If reward token will have less than 18 decimals, calculations will be wrong and user will receive less tokens than he should be receiving.

Proof of Concept

If deposit token or reward token has 9 decimals

  • getMaximumRewards() will return almost zero and pool will created with 0 reward token transfer.

  • getRewards(poolId, receiptId) which is called from withdraw() function will return less reward to users compare to user should get and owner wanted to distribute.

Tools Used

Manual Analysis

calculate rewards with wei only.

#0 - illuzen

2022-05-10T07:39:19Z

Valid

#2 - gititGoro

2022-06-14T03:15:41Z

Duplicate of #47

Wrap transfer ERC20 transaction into require

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

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

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

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

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

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

  • removing a bool success will save some gas and best practice is to wrap transfer ERC20 transactions to require directly.

Use

require(IERC20(pool.depositToken).transferFrom(msg.sender, address(this), amount), 'Token transfer failed');

Instead of

bool success = IERC20(pool.depositToken).transferFrom(msg.sender, address(this), amount); require(success, 'Token transfer failed');

Remove unnecessary uint tax

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

Use

success = success && IERC20(pool.rewardTokens[i]).transfer(globalBeneficiary, taxes[poolId][i]); taxes[poolId][i] = 0;

Instead of

uint tax = taxes[poolId][i]; taxes[poolId][i] = 0; success = success && IERC20(pool.rewardTokens[i]).transfer(globalBeneficiary, tax);

#0 - illuzen

2022-05-12T08:34:32Z

all duplicates

#1 - gititGoro

2022-06-05T01:36:20Z

For the uint tax item, the developer is intentionally avoiding a reentrancy threat by ordering the state updates in this manner. That item is therefore invalid.

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter