PoolTogether Aave v3 contest - reassor's results

A protocol for no loss prize savings on Ethereum.

General Information

Platform: Code4rena

Start Date: 29/04/2022

Pot Size: $22,000 USDC

Total HM: 6

Participants: 40

Period: 3 days

Judge: Justin Goro

Total Solo HM: 2

Id: 114

League: ETH

PoolTogether

Findings Distribution

Researcher Performance

Rank: 14/40

Findings: 2

Award: $377.45

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: MaratCerby

Also found by: CertoraInc, IllIllI, berndartmueller, cccz, reassor

Labels

bug
duplicate
2 (Med Risk)

Awards

309.1634 USDC - $309.16

External Links

Lines of code

https://github.com/pooltogether/aave-v3-yield-source/blob/e63d1b0e396a5bce89f093630c282ca1c6627e44/contracts/AaveV3YieldSource.sol#L231-L242

Vulnerability details

Impact

Contract AaveV3YieldSource allows depositing tokens via supplyTokenTo function. Amount of tokens to transfer is based on passed argument _depositAmount and is missing support for tokens with built-in fees. One of the popular tokens that implements such a fee (but currently is set to 0) is USDT.

The severity of vulnerability has been raised to medium since the "areas of concerns" includes shares/tokens peg at 1:1 ratio.

Proof of Concept

Used Tools

Manual Review / VSCode

It is recommended to add support for ERC20 tokens with built-in fees. Example of the implementation:

(..) uint256 _beforeBalance = _underlyingAssetAddress.balanceOf(address(this)); IERC20(_underlyingAssetAddress).safeTransferFrom(msg.sender, address(this), _depositAmount); uint256 _afterBalance = _underlyingAssetAddress.balanceOf(address(this)); uint256 receivedTokens = _afterBalance - _beforeBalance (..)

#0 - PierrickGT

2022-05-03T22:57:39Z

Findings Information

🌟 Selected for report: MaratCerby

Also found by: 0x52, 0xDjango, 0xf15ers, Dravee, GimelSec, IllIllI, Picodes, delfin454000, gzeon, hake, kebabsec, pauliax, reassor, z3s

Labels

bug
QA (Quality Assurance)

Awards

68.2909 USDC - $68.29

External Links

1. Obsolete usage of SafeMath

Risk

Low

Impact

Contract AaveV3YieldSource is using SafeMath library for uint256. The contract is prepared for solidity 0.8.10 and using SafeMath is obsolete since the overflow/underflow security checks are built-in and done automatically for solidity versions >= 0.8.0 for all calculations unless marked with unchecked {}.

Proof of Concept

Used Tools

Manual Review / VSCode

It is recommended to remove SafeMath from the contract.

2. Invalid setting decimals

Risk

Low

Impact

Constructor AaveV3YieldSource.constructor allows setting decimals value in constructor. Based on the comments in the code the value of decimals should be equal to the decimals of the token used to deposit into the pool. Setting it by the user who is deploying the contract makes the process prone to errors.

Comment in AaveV3YieldSource contract:

* @dev This value should be equal to the decimals of the token used to deposit into the pool.

Proof of Concept

Used Tools

Manual Review / VSCode

It is recommended to set _decimals by making external call to aToken.decimals().

3. Use immutable storage variables

Risk

Non-Critical

Impact

Contract AaveV3YieldSource has multiple storage addresses that are only set in constructor but are not marked as immutable.

Proof of Concept

Used Tools

Manual Review / VSCode

It is recommended to mark listed storage variables as immutable.

4. Redundant code for checking aToken address

Risk

Non-Critical

Impact

Function AaveV3YieldSource.transferERC20 is checking if the passed _token address argument is not a aToken address. Since there is already defined function _requireNotAToken that performs such a check it is better to reuse existing implementation.

Proof of Concept

Used Tools

Manual Review / VSCode

It is recommended to use _requireNotAToken in AaveV3YieldSource.transferERC20 function.

#0 - PierrickGT

2022-05-04T16:03:43Z

  1. Obsolete usage of SafeMath

Duplicate of https://github.com/code-423n4/2022-04-pooltogether-findings/issues/11

  1. Invalid setting decimals

As mentioned in a previous issue, we set this value in our deploy script, this way we are sure the Ticket contract and the yield source share the same number of decimals.

  1. Use immutable storage variables

Duplicate of https://github.com/code-423n4/2022-04-pooltogether-findings/issues/1

  1. Redundant code for checking aToken address

Duplicate of https://github.com/code-423n4/2022-04-pooltogether-findings/issues/4

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