• LISA
    LISA
    • Public Scans
    • My Scans
    1. Scan
    2. ...
    2025-06-23 01:43:58
    Public
    Full Disclosure

    SWC-120 Old Blockhash Vulnerability

    high1
    Created By:
    Credit Usage:

    Attacker can predict block hash as zero after 256 blocks, allowing guaranteed win

    HIGH

    Description

    The contract uses blockhash(blockNumber) to determine the correctness of a user's guess. However, blockhash returns zero for blocks older than 256 blocks. An attacker can lock in a guess of zero and wait until the target block is more than 256 blocks old. When settle() is called, blockhash returns zero, matching the attacker's guess, allowing them to steal the funds. This flaw makes the game trivially exploitable.

    Recommendation

    Add a check in settle() to ensure the current block is within 256 blocks of the guessed block. Modify the require statement to require(block.number > guesses[msg.sender].block && block.number <= guesses[msg.sender].block + 256, "Settlement window expired"); This ensures blockhash returns the actual hash, not zero.

    Affected Lines

    Line 25 – 37