Venus Prime - nadin's results

Earn, borrow & lend on the #1 Decentralized Money Market on the BNB chain.

General Information

Platform: Code4rena

Start Date: 28/09/2023

Pot Size: $36,500 USDC

Total HM: 5

Participants: 115

Period: 6 days

Judge: 0xDjango

Total Solo HM: 1

Id: 290

League: ETH

Venus Protocol

Findings Distribution

Researcher Performance

Rank: 106/115

Findings: 1

Award: $4.37

QA:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Lines of code

https://github.com/code-423n4/2023-09-venus/blob/b11d9ef9db8237678567e66759003138f2368d23/contracts/Tokens/Prime/PrimeLiquidityProvider.sol#L249-L272

Vulnerability details

Impact

Inaccuracy of block.number will affect the calculation of accrueTokens(). That will affect functions like PrimeLiquidityProvider.sol#_setTokenDistributionSpeed() , Prime.sol#accrueInterest().

Proof of Concept

  • According to the documentation where this code will be deployed:
Blockchains where this code will be deployed: BNB Chain, Ethereum mainnet, Arbitrum, Polygon zkEVM, opBNB.
  • While block.number works reasonably well on Ethereum's mainnet, where new blocks are produced at ~12s intervals, it can become problematic on other chains, especially L2 networks, where blocks can be produced much more frequently, potentially every few seconds, and/or have variable rates of production. This can cause inconsistencies in the timing mechanism, therefore significantly affecting the time-weighted aspect to the PrimeLiquidityProvider.sol#accrueTokens() function.
  • For example according to Arbitrum Docs, block.number returns the most recently synced L1 block number. Once per minute, the block number in the Sequencer is synced to the actual L1 block number. Using block.number as a clock can lead to inaccurate timing.
  • It also presents an issue for Polygon zkEVM , opBNB.
  • Here is the affected line of code : see here
276: function getBlockNumber() public view virtual returns (uint256) { 277: return block.number; 278: } ---SNIP--- 249: function accrueTokens(address token_) public { ---SNIP--- 254: uint256 blockNumber = getBlockNumber(); 255: uint256 deltaBlocks = blockNumber - lastAccruedBlock[token_]; // @audit do not use of block.number on L2 to calculate this

Tools Used

Manual review

Use block.timestamp rather than block.number.

Assessed type

Timing

#0 - c4-pre-sort

2023-10-05T00:49:37Z

0xRobocop marked the issue as duplicate of #132

#1 - c4-judge

2023-10-31T19:34:39Z

fatherGoose1 changed the severity to QA (Quality Assurance)

#2 - c4-judge

2023-11-03T01:43:00Z

fatherGoose1 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