PoolTogether - erebus's results

A protocol for no-loss prize savings

General Information

Platform: Code4rena

Start Date: 07/07/2023

Pot Size: $121,650 USDC

Total HM: 36

Participants: 111

Period: 7 days

Judge: Picodes

Total Solo HM: 13

Id: 258

League: ETH

PoolTogether

Findings Distribution

Researcher Performance

Rank: 101/111

Findings: 1

Award: $15.92

QA:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

15.9228 USDC - $15.92

Labels

bug
downgraded by judge
grade-b
QA (Quality Assurance)
sponsor confirmed
Q-19

External Links

Lines of code

https://github.com/GenerationSoftware/pt-v5-twab-controller/blob/0145eeac23301ee5338c659422dd6d69234f5d50/src/libraries/ObservationLib.sol#L16

Vulnerability details

Impact

The developers are using a constant named MAX_CARDINALITY as the maximum size of the _observations parameter

uint16 constant MAX_CARDINALITY = 365; // 1 year function binarySearch( Observation[MAX_CARDINALITY] storage _observations, uint24 _newestObservationIndex, uint24 _oldestObservationIndex, uint32 _target, uint16 _cardinality, uint32 _time )

which is used as a buffer to store one year's observations and do search through the function binarySearch. However, it only defines 365 observations (not the Solidity's year, which is 60*60*24*365 >>> 365) for the whole year, meaning that it may not be enough (for sure) to store all of the records/observations.

Proof of Concept

Suppose that the rate of observations is twice a day. That means, for the day 182/183 it will start overwriting the initial ones (ring buffer) which leads to just searching for a "time-block" of 6 months instead of the year the devs wanted. From the code:

/** * @dev Sets max ring buffer length in the Account.observations Observation list. * As users transfer/mint/burn tickets new Observation checkpoints are recorded. * The current `MAX_CARDINALITY` guarantees a one year minimum, of accurate historical lookups. ...

Tools Used

Manual analysis

Use the 1 year from Solidity instead of hard-coding the value (check for gas too because loading every time such a big array would make it cost A LOT, which could incur in an OOG)

Assessed type

Error

#0 - asselstine

2023-07-20T20:40:07Z

1 years is no longer valid Solidity, but I agree that we need harmony between the number of observations and the granularity of observations to get a consistent length of recorded history

#1 - c4-sponsor

2023-07-20T20:40:11Z

asselstine marked the issue as sponsor confirmed

#2 - Picodes

2023-08-07T17:20:26Z

Downgrading to low, as assuming the contract is properly configured and PERIOD_LENGTH is correct it would store for ex 1 observation / day so would indeed have a 1 year lookup.

#3 - c4-judge

2023-08-07T17:20:30Z

Picodes changed the severity to QA (Quality Assurance)

#4 - c4-judge

2023-08-08T14:32:42Z

Picodes marked the issue as grade-b

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