BriVault

First Flight #52
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Impact: low
Likelihood: low
Invalid

Inconsistency in time check lets users join exactly at `eventStartDate`

Root + Impact

Users can still call joinEvent() at the exact eventStartDate , while deposit is already blocked and this creates a scenerio where joining is possible but depositing is not

Description

  • Once the event starts at eventStartDate, both depositing and joining should be blocked to ensure a fair and consistent cutoff.

  • However, joinEvent reverts only when block.timestamp > eventStartDate as a result users can still join at EXACTLY the eventStartDate even though deposits can no loner be made.

function deposit(uint256 assets, address receiver) public override returns (uint256) {
require(receiver != address(0));
@> if (block.timestamp >= eventStartDate) {
revert eventStarted();
}
...
}
function joinEvent(uint256 countryId) public {
if (stakedAsset[msg.sender] == 0) {
revert noDeposit();
}
...
@> if (block.timestamp > eventStartDate) {
revert eventStarted();
}
...
}

Risk

Likelihood:

  • This will occur at the exact moment the event starts, a user can still join the event even when when its not supposed to be so

Impact:

  • Inconsistent state and fairness issues, including an imbalance between who can still join versus who can no longer deposit at the same time.

Proof of Concept

At exactly eventStartDate, joinEvent() succeeds while deposit reverts.

function test_JoinAtStart_DepositBlocked() public {
// precondition: user deposited before start, countries set
uint256 start = vault.eventStartDate();
vm.warp(start);
vm.prank(user);
vault.joinEvent(0); // succeeds (join uses >)
vm.prank(other);
vm.expectRevert(BriVault.eventStarted.selector);
vault.deposit(1e18, other); // reverts (deposit uses >=)
}

Recommended Mitigation

Modify the check to ensure that users cant join the event once it has already started even at the exact time it started

- if (block.timestamp > eventStartDate) {
+ if (block.timestamp >= eventStartDate) {
revert eventStarted();
}
Updates

Appeal created

bube Lead Judge 19 days ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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

Give us feedback!