Hello team,
The SeasonFacet
contract within the Beanstalk project is susceptible to a vulnerability that allows for manipulation of the block timestamp. This vulnerability could potentially be exploited by miners or malicious actors to influence the contract's logic, leading to unintended outcomes. The issue lies in the contract's reliance on the block.timestamp
for determining the current season, which can be manipulated by altering the timestamp of the block being mined.
Setup the Test Environment: Ensure that the Hardhat environment is correctly set up with the necessary dependencies, including @nomicfoundation/hardhat-network-helpers
for manipulating the block timestamp.
Deploy the SeasonFacet Contract: Deploy the SeasonFacet
contract to a local or test network using Hardhat.
Manipulate the Block Timestamp: Use the time.increase
function from @nomicfoundation/hardhat-network-helpers
to advance the block timestamp by a significant amount, simulating a future time.
Call the seasonTime
Function: After manipulating the block timestamp, call the seasonTime
function on the SeasonFacet
contract.
Observe the Output: The output should indicate that the seasonTime
function did not return the expected value, suggesting that the block timestamp manipulation did not have the intended effect on the contract's logic.
This vulnerability could allow miners or malicious actors to manipulate the block timestamp to influence the outcome of transactions or contract logic, potentially leading to financial loss or other unintended consequences for users of the Beanstalk project.
Manual code audit
To mitigate this vulnerability, consider implementing a more robust mechanism for determining the current time, such as using block numbers or a combination of block numbers and timestamps. Additionally, ensure that any logic dependent on the block timestamp is thoroughly tested to confirm its resilience against manipulation.
This fix involves using block numbers to determine the current season, which is less susceptible to manipulation compared to relying solely on the block timestamp.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.