Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: high
Valid

[H-4] Inconsistent `block.prevrandao` Values Across Chains Compromise Randomness Logic and `PUSH0` Opcode Compatibility Issues

Description:

Issue 1: block.prevrandao Differences
In the functions choosingRam::selectRamIfNotSelected() and choosingRam::increaseValuesOfParticipants(), the block.prevrandao value differs significantly across some chains, causing predictable randomness, which compromises security:

  • Arbitrum: Returns a constant value of 1 for block.prevrandao.

  • zkSync: Returns a constant value of 2500000000000000 for block.prevrandao.
    This behavior allows an attacker to predict the selected RAM, undermining the randomness logic.

Issue 2: PUSH0 Opcode Compatibility
The PUSH0 opcode, introduced with the Ethereum Shanghai/Capella upgrades (EIP-3855), simplifies pushing a zero onto the stack. However, several blockchains and Layer 2 solutions may not support this opcode yet, leading to deployment failures and execution errors in contracts that use it.
Chains and L2s that may not support PUSH0:

  • Binance Smart Chain (BSC)

  • ZK-Rollups (e.g., zkSync, StarkNet)

  • Arbitrum

Impact:

  • Randomness Compromise: The predictability of block.prevrandao on Arbitrum and zkSync breaks the randomness logic, enabling attackers to manipulate and predict the randomly selected RAM.

  • PUSH0 Incompatibility: Contracts using PUSH0 will face deployment failures and runtime errors on non-supporting chains, leading to incompatibility issues.

Proof of Concept:

block.prevrandao:

Recommended Mitigation:

  • Randomness: Use a more secure and reliable method for randomness, such as Chainlink VRF (Verifiable Random Function), to avoid predictability issues across different chains.

  • PUSH0 Compatibility: Verify the support for PUSH0 on the target chain before deploying contracts. For broader compatibility, consider alternative approaches to achieve similar functionality without relying on PUSH0.

Updates

Lead Judging Commences

bube Lead Judge
about 1 year ago
bube Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Weak randomness in `ChoosingRam::increaseValuesOfParticipants`

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.