Venus Prime - nisedo'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: 111/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#L274-L278 https://github.com/code-423n4/2023-09-venus/blob/b11d9ef9db8237678567e66759003138f2368d23/contracts/Tokens/Prime/PrimeLiquidityProvider.sol#L249-L272 https://github.com/code-423n4/2023-09-venus/blob/b11d9ef9db8237678567e66759003138f2368d23/contracts/Tokens/Prime/PrimeLiquidityProvider.sol#L286-L301

Vulnerability details

Vulnerability Details

The PrimeLiquidityProvider.accrueTokens() and PrimeLiquidityProvider._initializeToken() functions rely on block.number for calculating token accruals and initializing token distributions. This approach can lead to inconsistent behavior when deployed on Layer 2 solutions like Arbitrum or Optimism (opBNB), where block.number doesn't operate the same way as it does on Ethereum mainnet.

getBlockNumber():

function getBlockNumber() public view virtual returns (uint256) {
    return block.number; //@audit-issue block.number means different things on different L2s	
}

For PrimeLiquidityProvider.accrueTokens():

uint256 blockNumber = getBlockNumber();
uint256 deltaBlocks = blockNumber - lastAccruedBlock[token_];

For PrimeLiquidityProvider._initializeToken():

uint256 blockNumber = getBlockNumber();
uint256 initializedBlock = lastAccruedBlock[token_];

Impact

  • Inconsistent Behavior: The functions may not work as intended when deployed on Layer 2 solutions, affecting the token accrual and distribution mechanisms.
  • Exploitability: Malicious actors may exploit the varying behaviors of block.number on different platforms to manipulate token accrual or initialization.

Tools Used

  • Manual review
  • Solodit

Use block.timestamp: Consider using block.timestamp instead of block.number to measure the time between actions, as block.timestamp is more consistent across different blockchains.

Assessed type

Other

#0 - c4-pre-sort

2023-10-05T00:57:14Z

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:54:30Z

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